@@ -11,9 +11,47 @@ private import codeql.ruby.Frameworks
11
11
private import codeql.ruby.dataflow.RemoteFlowSources
12
12
private import codeql.ruby.ApiGraphs
13
13
14
+ /**
15
+ * A data-flow node that constructs a SQL statement.
16
+ *
17
+ * Often, it is worthy of an alert if a SQL statement is constructed such that
18
+ * executing it would be a security risk.
19
+ *
20
+ * If it is important that the SQL statement is indeed executed, use `SqlExecution`.
21
+ *
22
+ * Extend this class to refine existing API models. If you want to model new APIs,
23
+ * extend `SqlConstruction::Range` instead.
24
+ */
25
+ class SqlConstruction extends DataFlow:: Node instanceof SqlConstruction:: Range {
26
+ /** Gets the argument that specifies the SQL statements to be constructed. */
27
+ DataFlow:: Node getSql ( ) { result = super .getSql ( ) }
28
+ }
29
+
30
+ /** Provides a class for modeling new SQL execution APIs. */
31
+ module SqlConstruction {
32
+ /**
33
+ * A data-flow node that constructs a SQL statement.
34
+ *
35
+ * Often, it is worthy of an alert if a SQL statement is constructed such that
36
+ * executing it would be a security risk.
37
+ *
38
+ * If it is important that the SQL statement is indeed executed, use `SqlExecution`.
39
+ *
40
+ * Extend this class to model new APIs. If you want to refine existing API models,
41
+ * extend `SqlConstruction` instead.
42
+ */
43
+ abstract class Range extends DataFlow:: Node {
44
+ /** Gets the argument that specifies the SQL statements to be constructed. */
45
+ abstract DataFlow:: Node getSql ( ) ;
46
+ }
47
+ }
48
+
14
49
/**
15
50
* A data-flow node that executes SQL statements.
16
51
*
52
+ * If the context of interest is such that merely constructing a SQL statement
53
+ * would be valuable to report, consider using `SqlConstruction`.
54
+ *
17
55
* Extend this class to refine existing API models. If you want to model new APIs,
18
56
* extend `SqlExecution::Range` instead.
19
57
*/
@@ -27,6 +65,9 @@ module SqlExecution {
27
65
/**
28
66
* A data-flow node that executes SQL statements.
29
67
*
68
+ * If the context of interest is such that merely constructing a SQL
69
+ * statement would be valuable to report, consider using `SqlConstruction`.
70
+ *
30
71
* Extend this class to model new APIs. If you want to refine existing API models,
31
72
* extend `SqlExecution` instead.
32
73
*/
0 commit comments