Skip to content

Commit 225c96e

Browse files
committed
Merge branch 'main' of https://github.com/github/codeql
2 parents 37361d9 + 8d3ed68 commit 225c96e

File tree

291 files changed

+55592
-52871
lines changed

Some content is hidden

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

291 files changed

+55592
-52871
lines changed

cpp/ql/lib/semmle/code/cpp/models/Models.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ private import implementations.Accept
3535
private import implementations.Poll
3636
private import implementations.Select
3737
private import implementations.MySql
38+
private import implementations.ODBC
3839
private import implementations.SqLite3
3940
private import implementations.PostgreSql
4041
private import implementations.System
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Provides implementation classes modeling the ODBC C/C++ API.
3+
* See `semmle.code.cpp.models.Models` for usage information.
4+
*/
5+
6+
private import semmle.code.cpp.models.interfaces.Sql
7+
private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs
8+
9+
/**
10+
* The `SQLExecDirect`, and `SQLPrepare` from the ODBC C/C++ API:
11+
* https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlexecdirect-function?view=sql-server-ver16
12+
* https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlprepare-function?view=sql-server-ver16
13+
*
14+
* Note, `SQLExecute` is not included because it operates on a SQLHSTMT type, not a string.
15+
* The SQLHSTMT parameter for `SQLExecute` is set through a `SQLPrepare`, which is modeled.
16+
* The other source of input to a `SQLExecute` is via a `SQLBindParameter`, which sanitizes user input,
17+
* and would be considered a barrier to SQL injection.
18+
*/
19+
private class ODBCExecutionFunction extends SqlExecutionFunction {
20+
ODBCExecutionFunction() { this.hasGlobalName(["SQLExecDirect", "SQLPrepare"]) }
21+
22+
override predicate hasSqlArgument(FunctionInput input) { input.isParameterDeref(1) }
23+
}
24+
// NOTE: no need to define a barrier explicitly.
25+
// `SQLBindParameter` is the typical means for sanitizing user input.
26+
// https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlbindparameter-function?view=sql-server-ver16
27+
// First a query is establisehed via `SQLPrepare`, then parameters are bound via `SQLBindParameter`, before
28+
// the query is executed via `SQLExecute`. We are not modeling SQLExecute, so we do not need to model SQLBindParameter.

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/ModulusAnalysis.qll

Lines changed: 0 additions & 328 deletions
This file was deleted.

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/ModulusAnalysisSpecific.qll

Lines changed: 0 additions & 8 deletions
This file was deleted.

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/RangeAnalysisImpl.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ module Sem implements Semantic {
7878

7979
predicate guardDirectlyControlsSsaRead = semGuardDirectlyControlsSsaRead/3;
8080

81+
predicate guardControlsSsaRead = semGuardControlsSsaRead/3;
82+
8183
class Type = SemType;
8284

8385
class IntegerType = SemIntegerType;
@@ -169,8 +171,8 @@ module AllBounds implements BoundSig<SemLocation, Sem, FloatDelta> {
169171
private module ModulusAnalysisInstantiated implements ModulusAnalysisSig<Sem> {
170172
class ModBound = AllBounds::SemBound;
171173

172-
private import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.ModulusAnalysis as MA
173-
import MA::ModulusAnalysis<FloatDelta, AllBounds, Util>
174+
private import codeql.rangeanalysis.ModulusAnalysis as MA
175+
import MA::ModulusAnalysis<SemLocation, Sem, FloatDelta, AllBounds, Util>
174176
}
175177

176178
module Util = RangeUtil<FloatDelta, CppLangImplConstant>;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added SQL API models for `ODBC`.

0 commit comments

Comments
 (0)