Skip to content

Commit f5301aa

Browse files
authored
Merge branch 'main' into add-activerecord-annotate
2 parents 9a0a949 + 80cbddf commit f5301aa

File tree

55 files changed

+249
-108
lines changed

Some content is hidden

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

55 files changed

+249
-108
lines changed

.github/workflows/ql-for-ql-build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
uses: github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
2020
with:
2121
languages: javascript # does not matter
22-
tools: latest
2322
- name: Get CodeQL version
2423
id: get-codeql-version
2524
run: |
@@ -184,7 +183,6 @@ jobs:
184183
languages: ql
185184
db-location: ${{ runner.temp }}/db
186185
config-file: ./ql-for-ql-config.yml
187-
tools: latest
188186

189187
- name: Perform CodeQL Analysis
190188
uses: github/codeql-action/analyze@aa93aea877e5fb8841bcb1193f672abf6e9f2980
@@ -224,4 +222,4 @@ jobs:
224222
uses: actions/upload-artifact@v3
225223
with:
226224
name: combined.sarif
227-
path: combined.sarif
225+
path: combined.sarif
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 data-flow models for `java.util.Properites`. Additional results may be found where relevant data is stored in and then retrieved from a `Properties` instance.

java/ql/lib/semmle/code/java/dataflow/internal/ContainerFlow.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ private class ContainerFlowSummaries extends SummaryModelCsv {
241241
"java.util;NavigableSet;true;pollLast;();;Argument[-1].Element;ReturnValue;value;manual",
242242
"java.util;NavigableSet;true;subSet;(Object,boolean,Object,boolean);;Argument[-1].Element;ReturnValue.Element;value;manual",
243243
"java.util;NavigableSet;true;tailSet;(Object,boolean);;Argument[-1].Element;ReturnValue.Element;value;manual",
244+
"java.util;Properties;true;getProperty;(String);;Argument[-1].MapValue;ReturnValue;value;manual",
245+
"java.util;Properties;true;getProperty;(String,String);;Argument[-1].MapValue;ReturnValue;value;manual",
246+
"java.util;Properties;true;getProperty;(String,String);;Argument[1];ReturnValue;value;manual",
244247
"java.util;Scanner;true;next;(Pattern);;Argument[-1];ReturnValue;taint;manual",
245248
"java.util;Scanner;true;next;(String);;Argument[-1];ReturnValue;taint;manual",
246249
"java.util;SortedMap;true;headMap;(Object);;Argument[-1].MapKey;ReturnValue.MapKey;value;manual",

java/ql/lib/semmle/code/java/frameworks/Properties.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ class TypeProperty extends Class {
1010
}
1111

1212
/** The `getProperty` method of the class `java.util.Properties`. */
13-
class PropertiesGetPropertyMethod extends ValuePreservingMethod {
13+
class PropertiesGetPropertyMethod extends Method {
1414
PropertiesGetPropertyMethod() {
1515
getDeclaringType() instanceof TypeProperty and
1616
hasName("getProperty")
1717
}
18-
19-
override predicate returnsValue(int arg) { arg = 1 }
2018
}
2119

2220
/** The `get` method of the class `java.util.Properties`. */

java/ql/test/library-tests/dataflow/collections/Test.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,14 @@ public void run3() {
7878
sink(x18); // Flow
7979
});
8080
}
81+
82+
public void run4() {
83+
Properties p = new Properties();
84+
p.put("key", tainted);
85+
sink(p.getProperty("key")); // Flow
86+
sink(p.getProperty("key", "defaultValue")); // Flow
87+
88+
Properties clean = new Properties();
89+
sink(clean.getProperty("key", tainted)); // Flow
90+
}
8191
}

java/ql/test/library-tests/dataflow/collections/flow.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111
| Test.java:49:20:49:26 | tainted | Test.java:60:12:60:14 | x14 |
1212
| Test.java:73:11:73:17 | tainted | Test.java:75:10:75:12 | x17 |
1313
| Test.java:73:11:73:17 | tainted | Test.java:78:12:78:14 | x18 |
14+
| Test.java:84:18:84:24 | tainted | Test.java:85:10:85:29 | getProperty(...) |
15+
| Test.java:84:18:84:24 | tainted | Test.java:86:10:86:45 | getProperty(...) |
16+
| Test.java:89:35:89:41 | tainted | Test.java:89:10:89:42 | getProperty(...) |

javascript/ql/examples/queries/dataflow/TemplateInjection/TemplateInjection.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import DataFlow::PathGraph
1414
/**
1515
* Gets the name of an unescaped placeholder in a lodash template.
1616
*
17-
* For example, the string `<h1><%= title %></h1>` contains the placeholder `title`.
17+
* For example, the string `"<h1><%= title %></h1>"` contains the placeholder "title".
1818
*/
1919
bindingset[s]
2020
string getAPlaceholderInString(string s) {

javascript/ql/lib/definitions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private predicate variableDefLookup(VarAccess va, AstNode def, string kind) {
4545

4646
/**
4747
* Holds if variable access `va` is of kind `kind` and refers to the
48-
* variable declaration.
48+
* variable declaration `decl`.
4949
*
5050
* For example, in the statement `var x = 42, y = x;`, the initializing
5151
* expression of `y` is a variable access `x` of kind `"V"` that refers to

javascript/ql/lib/semmle/javascript/BasicBlocks.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class BasicBlock extends @cfg_node, NodeInStmtContainer {
146146
/** Holds if this basic block uses variable `v` in its `i`th node `u`. */
147147
predicate useAt(int i, Variable v, VarUse u) { useAt(this, i, v, u) }
148148

149-
/** Holds if this basic block defines variable `v` in its `i`th node `u`. */
149+
/** Holds if this basic block defines variable `v` in its `i`th node `d`. */
150150
predicate defAt(int i, Variable v, VarDef d) { defAt(this, i, v, d) }
151151

152152
/**

javascript/ql/lib/semmle/javascript/CharacterEscapes.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module CharacterEscapes {
7575
}
7676

7777
/**
78-
* Gets a character in `n` that is preceded by a single useless backslash, resulting in a likely regular expression mistake explained by `mistake`.
78+
* Gets a character in `src` that is preceded by a single useless backslash, resulting in a likely regular expression mistake explained by `mistake`.
7979
*
8080
* The character is the `i`th character of the raw string value of `rawStringNode`.
8181
*/

0 commit comments

Comments
 (0)