Skip to content

Commit 1a33a3b

Browse files
committed
Merge branch 'master' into remove-initialize-this-from-value-numbering
2 parents d49c0f7 + ff6936c commit 1a33a3b

File tree

20 files changed

+303
-24
lines changed

20 files changed

+303
-24
lines changed

change-notes/1.25/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
| Client-side URL redirect (`js/client-side-unvalidated-url-redirection`) | Fewer results | This query now recognizes additional safe patterns of doing URL redirects. |
4444
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving NoSQL code operators are now recognized. |
4545
| Expression has no effect (`js/useless-expression`) | Fewer results | This query no longer flags an expression when that expression is the only content of the containing file. |
46+
| Hard-coded credentials (`js/hardcoded-credentials`) | More results | This query now recognizes hard-coded credentials sent via HTTP authorization headers. |
4647
| Incomplete URL scheme check (`js/incomplete-url-scheme-check`) | More results | This query now recognizes additional url scheme checks. |
4748
| Misspelled variable name (`js/misspelled-variable-name`) | Message changed | The message for this query now correctly identifies the misspelled variable in additional cases. |
4849
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | More results | This query now recognizes additional utility functions as vulnerable to prototype polution. |

config/sync-files.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,41 @@ def file_checksum(filename):
5959
return hashlib.sha1(file_handle.read()).hexdigest()
6060

6161
def check_group(group_name, files, master_file_picker, emit_error):
62-
checksums = {file_checksum(f) for f in files}
62+
extant_files = [f for f in files if path.isfile(f)]
63+
if len(extant_files) == 0:
64+
emit_error(__file__, 0, "No files found from group '" + group_name + "'.")
65+
emit_error(__file__, 0,
66+
"Create one of the following files, and then run this script with "
67+
"the --latest switch to sync it to the other file locations.")
68+
for filename in files:
69+
emit_error(__file__, 0, " " + filename)
70+
return
71+
72+
checksums = {file_checksum(f) for f in extant_files}
6373

64-
if len(checksums) == 1:
74+
if len(checksums) == 1 and len(extant_files) == len(files):
75+
# All files are present and identical.
6576
return
6677

67-
master_file = master_file_picker(files)
78+
master_file = master_file_picker(extant_files)
6879
if master_file is None:
6980
emit_error(__file__, 0,
7081
"Files from group '"+ group_name +"' not in sync.")
7182
emit_error(__file__, 0,
7283
"Run this script with a file-name argument among the "
7384
"following to overwrite the remaining files with the contents "
74-
"of that file or run with the --latest switch to update each "
85+
"of that file, or run with the --latest switch to update each "
7586
"group of files from the most recently modified file in the group.")
76-
for filename in files:
87+
for filename in extant_files:
7788
emit_error(__file__, 0, " " + filename)
7889
else:
7990
print(" Syncing others from", master_file)
8091
for filename in files:
8192
if filename == master_file:
8293
continue
8394
print(" " + filename)
84-
os.replace(filename, filename + '~')
95+
if path.isfile(filename):
96+
os.replace(filename, filename + '~')
8597
shutil.copy(master_file, filename)
8698
print(" Backups written with '~' appended to file names")
8799

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/ValueNumbering.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class ValueNumber extends TValueNumber {
5656
or
5757
this instanceof TInitializeParameterValueNumber and result = "InitializeParameter"
5858
or
59+
this instanceof TConstantValueNumber and result = "Constant"
60+
or
5961
this instanceof TStringConstantValueNumber and result = "StringConstant"
6062
or
6163
this instanceof TFieldAddressValueNumber and result = "FieldAddress"

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class ValueNumber extends TValueNumber {
5656
or
5757
this instanceof TInitializeParameterValueNumber and result = "InitializeParameter"
5858
or
59+
this instanceof TConstantValueNumber and result = "Constant"
60+
or
5961
this instanceof TStringConstantValueNumber and result = "StringConstant"
6062
or
6163
this instanceof TFieldAddressValueNumber and result = "FieldAddress"

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class ValueNumber extends TValueNumber {
5656
or
5757
this instanceof TInitializeParameterValueNumber and result = "InitializeParameter"
5858
or
59+
this instanceof TConstantValueNumber and result = "Constant"
60+
or
5961
this instanceof TStringConstantValueNumber and result = "StringConstant"
6062
or
6163
this instanceof TFieldAddressValueNumber and result = "FieldAddress"

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/gvn/ValueNumbering.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class ValueNumber extends TValueNumber {
5656
or
5757
this instanceof TInitializeParameterValueNumber and result = "InitializeParameter"
5858
or
59+
this instanceof TConstantValueNumber and result = "Constant"
60+
or
5961
this instanceof TStringConstantValueNumber and result = "StringConstant"
6062
or
6163
this instanceof TFieldAddressValueNumber and result = "FieldAddress"

csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class ValueNumber extends TValueNumber {
5656
or
5757
this instanceof TInitializeParameterValueNumber and result = "InitializeParameter"
5858
or
59+
this instanceof TConstantValueNumber and result = "Constant"
60+
or
5961
this instanceof TStringConstantValueNumber and result = "StringConstant"
6062
or
6163
this instanceof TFieldAddressValueNumber and result = "FieldAddress"

java/ql/test/library-tests/typeflow/A.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,11 @@ public void put(String k, String v) {
8585
empty.put(k, v);
8686
}
8787
}
88+
89+
public void m8(Object[] xs, int i) {
90+
if (xs[i] instanceof Integer) {
91+
Object n = xs[i];
92+
Object r = n;
93+
}
94+
}
8895
}

java/ql/test/library-tests/typeflow/typeflow.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
| A.java:61:11:61:11 | x | Integer | false |
1313
| A.java:67:22:67:22 | x | Integer | false |
1414
| A.java:70:23:70:24 | x2 | Integer | false |
15+
| A.java:92:18:92:18 | n | Integer | false |

javascript/ql/src/semmle/javascript/dataflow/TaintTracking.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,26 @@ module TaintTracking {
827827
override predicate appliesTo(Configuration cfg) { any() }
828828
}
829829

830+
/** A check of the form `type x === "undefined"`, which sanitized `x` in its "then" branch. */
831+
class TypeOfUndefinedSanitizer extends AdditionalSanitizerGuardNode, DataFlow::ValueNode {
832+
Expr x;
833+
override EqualityTest astNode;
834+
835+
TypeOfUndefinedSanitizer() {
836+
exists(StringLiteral str, TypeofExpr typeof | astNode.hasOperands(str, typeof) |
837+
str.getValue() = "undefined" and
838+
typeof.getOperand() = x
839+
)
840+
}
841+
842+
override predicate sanitizes(boolean outcome, Expr e) {
843+
outcome = astNode.getPolarity() and
844+
e = x
845+
}
846+
847+
override predicate appliesTo(Configuration cfg) { any() }
848+
}
849+
830850
/** DEPRECATED. This class has been renamed to `MembershipTestSanitizer`. */
831851
deprecated class StringInclusionSanitizer = MembershipTestSanitizer;
832852

0 commit comments

Comments
 (0)