Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
abd6df3
Java: add Semmle/java team to CODEOWNERS
yh-semmle Sep 6, 2018
9179701
JavaScript: Add query for Node.js integration in Electron framework
bnxi Sep 6, 2018
ebbd3b3
Adding html encoding to EnablingNodeIntegration.qhelp
bnxi Sep 7, 2018
bd92cd1
Changing EOL in all files to unix format
bnxi Sep 7, 2018
302e271
Update EnablingNodeIntegration.expected
bnxi Sep 7, 2018
43a9d51
Update EnablingNodeIntegration.qhelp
bnxi Sep 7, 2018
02047ea
Edit .expected file
bnxi Sep 10, 2018
2d7109b
C++: initial implementation of a HashCons library.
kevinbackhouse Aug 23, 2018
3c6a9c0
C++: first tests for HashCons
Aug 23, 2018
8b8ec7c
C++: add literal tests
Aug 23, 2018
d8dc75a
C++: rename HashCons test
Aug 23, 2018
cf222c5
C++: treat constant-valued exprs structurally
Aug 23, 2018
a8895f4
C++: Support crement ops in HashCons
Aug 24, 2018
b8bd285
C++: support functions in HashCons
Aug 24, 2018
77c5a8e
C++: support impure binary operations in HashCons
Aug 25, 2018
e0af30a
C++: clean up commented-out code
Aug 25, 2018
3a5eb03
C++: change floating point value in test
Aug 27, 2018
91da02b
C++: uniqueness fixes for HashCons
Aug 27, 2018
e6314c5
C++: add support for enums in HashCons
Aug 27, 2018
fede8d6
C++: respond to PR comments
Aug 27, 2018
5549b6f
C++: HashCons for new, new[], sizeof, alignof
Aug 28, 2018
8f446aa
C++: fix handling of aligned allocators
Aug 28, 2018
752f39b
C++: initial support for aggregate initializers
Aug 29, 2018
85cfb02
C++: add HashCons for delete expressions
Aug 29, 2018
8189798
C++: HashCons for throw
Aug 29, 2018
cfeed30
C++: Hashcons tests for ArrayExpr
Aug 29, 2018
06a3e8f
C++: Hashcons for ?:, ExprCall, and weird stuff
Aug 29, 2018
246ae2d
C++: fix performance of argument hash-consing
Aug 30, 2018
fa9eeea
C++: remove implicit this handling in HashCons
Aug 29, 2018
9f476e5
C++: Simplify some code
Aug 30, 2018
c42ecfe
C++: Simplify HashCons for new and handle extents
Aug 30, 2018
2d098fe
fix HashCons for typeid of type
Aug 30, 2018
bbafcd9
C++: typeid and noexcept fixes in HashCons
Aug 31, 2018
166dba2
C++: accept test output
Sep 4, 2018
990bfb4
C++: change note for HashCons library
Sep 4, 2018
fb8ad93
C++: Uniqueness fixes for HashCons
Sep 6, 2018
cb9f126
C++: select example exprs for HashCons portably
Sep 6, 2018
0e44bf3
C++: Add import for LGTM
Sep 10, 2018
befca6c
Remove webview example and its reference in qlhelp file
bnxi Sep 11, 2018
fc087ff
Replaceing query and test files with suggested ones
bnxi Sep 11, 2018
ecd08d4
Chaning EOL in two files
bnxi Sep 12, 2018
1220b50
JS: whitelist _.bindAll-methods in js/unbound-event-handler-receiver
Sep 11, 2018
eb10f60
JS: whitelist decorator-bound methods in js/unbound-event-handler-rec…
Sep 11, 2018
fcc33ce
JS: whitelist auto-bind methods in js/unbound-event-handler-receiver
Sep 11, 2018
52013f3
JS: change notes for improved js/unbound-event-handler-receiver
Sep 13, 2018
ea37665
JS: move array-specific taint steps to separate class
Sep 11, 2018
763da72
JS: modernize old array taint steps
Sep 11, 2018
1a14b13
C++: migrate change note
Sep 13, 2018
4c13e6b
JS: add additional array-specific taint steps
Sep 11, 2018
cb2bd9e
JS: change notes for additional array taint steps
Sep 13, 2018
28050e1
Change to cpp/overflow-buffer to detect access to an array using a ne…
raulgarciamsft Sep 13, 2018
961ecfb
Merge pull request #187 from esben-semmle/js/additional-whitelisting-…
semmle-qlci Sep 14, 2018
81aeda6
JS: lower @precision of js/remote-property-injection
Sep 13, 2018
abbadf2
Merge pull request #192 from esben-semmle/js/additional-array-taint-s…
semmle-qlci Sep 14, 2018
8de269e
JS: add support for `fs-extra` in `NodeJSFileSystemAccess`
Aug 30, 2018
6d3c1a1
JS: introduce `fsModuleMember`
Aug 30, 2018
e2fac8a
JS: introduce concept: `FileNameSource`
Aug 30, 2018
a3562aa
Merge pull request #193 from esben-semmle/js/reduce-precision-of-remo…
asger-semmle Sep 14, 2018
33f98dd
JS: add query: js/stored-xss
Aug 30, 2018
5781b51
JS: change notes for js/stored-xss
Sep 3, 2018
444a09a
JS: add models of five file system libraries
Sep 5, 2018
7071c75
revert "Chaning EOL in two files"
bnxi Sep 14, 2018
e4b9d31
Merge pull request #194 from raulgarciamsft/overflow_buffer_negindex
geoffw0 Sep 14, 2018
782e91b
Merge pull request #167 from bnxi/NodeIntegration
semmle-qlci Sep 15, 2018
bb48421
JS: address doc review comments
Sep 17, 2018
b20fd3c
JS: recognize res.sendfile as alias for res.sendFile in Express
asger-semmle Sep 17, 2018
e2cdf5d
JavaScript: add string concatenation library
asger-semmle Aug 9, 2018
9384b85
JavaScript: ensure prefix sanitizers work for array.join()
asger-semmle Sep 17, 2018
46b2c19
C++: Initial attempt at IR-based value numbering
dave-bartolomeo Sep 18, 2018
86fe0ce
Merge pull request #107 from rdmarsh2/rdmarsh/cpp/HashCons
jbj Sep 18, 2018
43f0289
C++: Remove Phi instructions from previous IR generations
dave-bartolomeo Sep 18, 2018
89f2dbf
Merge pull request #195 from esben-semmle/js/reflected-xss-through-fi…
semmle-qlci Sep 19, 2018
2cedc81
JS: polish js/enabling-electron-renderer-node-integration meta info
Sep 17, 2018
1d793c0
JavaScript: fix expected output
asger-semmle Sep 19, 2018
7d69c84
Java: tweak some query metadata
yh-semmle Sep 19, 2018
2f4aa64
Merge pull request #200 from esben-semmle/js/post-polish-167
semmle-qlci Sep 19, 2018
4aca8f4
Merge pull request #201 from asger-semmle/string-concatenation-squashed
semmle-qlci Sep 19, 2018
bd15675
C++: Remove accidental add of IR.md
dave-bartolomeo Sep 19, 2018
b12c739
JavaScript: Normalize line endings of .js and .html files
dave-bartolomeo Sep 19, 2018
2b9f42b
JavaScript: Force LF for .json and .yml
dave-bartolomeo Sep 19, 2018
524c67c
JavaScript: Normalize .ts line endings to LF
dave-bartolomeo Sep 19, 2018
e06969d
JavaScript: Normalize .mjs files to LF
dave-bartolomeo Sep 20, 2018
4d46385
Merge pull request #206 from yh-semmle/java/codeowners
aschackmull Sep 20, 2018
f146e34
Merge pull request #207 from dave-bartolomeo/dave/JSNewlines
semmle-qlci Sep 20, 2018
27cee9b
C++: Handle inheritance conversions in IR GVN
dave-bartolomeo Sep 20, 2018
5a25602
C++: Move GVN out of "internal" directory
dave-bartolomeo Sep 20, 2018
69962bd
Merge pull request #203 from dave-bartolomeo/dave/GVN
rdmarsh2 Sep 20, 2018
b0ec929
Cast between semantically different integer types: HRESULT to/from a …
raulgarciamsft Sep 20, 2018
64b8a5b
Merge branch 'master' into users/raulga/HESULT
raulgarciamsft Sep 20, 2018
48c99fb
Setting a SECURITY_DESCRIPTOR’s DACL to NULL
raulgarciamsft Sep 20, 2018
5ccc1a3
Merge branch 'master' into master
raulgarciamsft Sep 20, 2018
e2a17e9
Merge remote-tracking branch 'upstream/rc/1.18' into mergeback-201809…
jbj Sep 21, 2018
c7aa5c1
CPP: Add a test of placement new for AV Rule 79.ql.
geoffw0 Sep 21, 2018
84f9900
CPP: Exclude placement new.
geoffw0 Sep 21, 2018
6f109a7
JS: add a test case for res.sendfile
asger-semmle Sep 21, 2018
5f467d2
JS: recognize CSRF middleware from lusca package
asger-semmle Sep 21, 2018
d2a04d3
JS: add change note
asger-semmle Sep 21, 2018
4797924
JS: review comments
asger-semmle Sep 21, 2018
d5a48ad
CPP: Additional test cases.
geoffw0 Sep 21, 2018
d281558
Merge pull request #218 from yh-semmle/java/query-severities
semmle-qlci Sep 21, 2018
e21a5e4
Merge pull request #214 from jbj/mergeback-20180921_104253
nickrolfe Sep 21, 2018
783be15
Fixing typos & ID.
raulgarciamsft Sep 21, 2018
94f752c
Merge branch 'users/raulga/HESULT' of https://github.com/raulgarciams…
raulgarciamsft Sep 21, 2018
75ef377
Replace Unicode apostrophe with ANSI single quote
raulgarciamsft Sep 21, 2018
3922082
CPP: Tidy and simplify AV Rule 79.ql.
geoffw0 Sep 21, 2018
c227872
Update .gitignore
raulgarciamsft Sep 21, 2018
8519f1a
Fixing tabs replaced to spaces
raulgarciamsft Sep 21, 2018
1fd7b4a
Merge branch 'master' of https://github.com/raulgarciamsft/ql
raulgarciamsft Sep 21, 2018
492d79e
CPP: Change note.
geoffw0 Sep 21, 2018
925c3b5
Adding semmle-extractor-options: --microsoft to test
raulgarciamsft Sep 21, 2018
242ee10
Major change in order to support the rule for C as well as cpp
raulgarciamsft Sep 21, 2018
caf4a76
Merge pull request #219 from geoffw0/resource-not-released
jbj Sep 22, 2018
aa267c8
C++: Force LF for .c,.cpp,.h,.hpp
dave-bartolomeo Sep 20, 2018
26abf5d
Force LF for basically everything.
dave-bartolomeo Sep 20, 2018
1f36f55
Normalize all text files to LF
dave-bartolomeo Sep 21, 2018
396d7ea
Mark several known binary extensions as `-text`
dave-bartolomeo Sep 21, 2018
d2f11dc
Merge pull request #209 from dave-bartolomeo/dave/CNewLines
jbj Sep 24, 2018
4617827
Merge pull request #213 from asger-semmle/sendfile
semmle-qlci Sep 24, 2018
7f56be6
Merge pull request #216 from asger-semmle/lusca-csrf
semmle-qlci Sep 24, 2018
2b5d150
C++: Test for IntMultToLong on char-typed numbers
jbj Sep 24, 2018
4d2e4c5
C++: Suppress IntMultToLong alert on char
jbj Sep 24, 2018
a56376a
C++: rename effectivelyConstant to likelySmall
jbj Sep 24, 2018
c3b523c
Fixing a missed reference to renamed file.
raulgarciamsft Sep 24, 2018
c750197
Removing tabs & reformatting
raulgarciamsft Sep 24, 2018
a566ffa
Fixed the test .expected file
raulgarciamsft Sep 24, 2018
4732526
Merge pull request #221 from jbj/IntMultToLong-char
geoffw0 Sep 24, 2018
614a8ef
Allow void* pointer arithmetic with sizeof
sauyon Sep 13, 2018
8f19efe
Merge pull request #211 from raulgarciamsft/users/raulga/HESULT
jbj Sep 25, 2018
1ab1110
JavaScript: Add new query flagging identity replacements.
Sep 24, 2018
ec9a3c8
JavaScript: Do not flag case-insensitive replace.
Sep 25, 2018
5fb22ba
JavaScript: Handle zero-width assertions and sequences.
Sep 25, 2018
659c67c
JavaScript: Produce friendlier message for empty-string replacements.
Sep 25, 2018
0e63ea1
JavaScript: Update tests.
Sep 25, 2018
2832956
Merge rc/1.18 into master.
adityasharad Sep 25, 2018
d6d27df
Removing all usage of single quotes
raulgarciamsft Sep 25, 2018
54493eb
Merge branch 'master' into master
raulgarciamsft Sep 25, 2018
9c219b9
Merge pull request #225 from sauyon/sizeofcheck
geoffw0 Sep 25, 2018
7c006d4
Merge pull request #222 from xiemaisi/js/identity-replacement
Sep 26, 2018
397c8b5
Merge pull request #212 from raulgarciamsft/master
jbj Sep 26, 2018
57f3ac8
Merge pull request #226 from adityasharad/merge/1.18-master-250918
nickrolfe Sep 26, 2018
75680db
Merge branch 'next' into qlucie/master
adityasharad Sep 26, 2018
4ff79b0
C++: Update HashCons test output.
adityasharad Sep 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[*.{ql,qll,qlref,dbscheme,qhelp}]
end_of_line = lf
[*]
end_of_line = lf
57 changes: 44 additions & 13 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,17 +1,48 @@
# The following file types will be normalized to LF line endings in the Git
# database, and will keep those LF line endings in the working tree even on
# Windows. Any other files will have whatever line endings they had when they
# were committed. If you add new entries below, you should renormalize the
# affected files by running the following from the root of this repo (requires
# Git 2.16 or greater):
# Text files will be normalized to LF line endings in the Git database, and will keep those LF line
# endings in the working tree even on Windows. If you make changes below, you should renormalize the
# affected files by running the following from the root of this repo (requires Git 2.16 or greater):
#
# git add --renormalize .
# git status [just to show what files were renormalized]
# git commit -m "Normalize line endings"
#
# Also, please update .editorconfig to handle any new entries as well.
*.ql eol=lf
*.qll eol=lf
*.qlref eol=lf
*.dbscheme eol=lf
*.qhelp eol=lf

# Anything Git auto-detects as text gets normalized and checked out as LF
* text=auto eol=lf

# Explicitly set a bunch of known extensions to text, in case auto detection gets confused.
*.ql text
*.qll text
*.qlref text
*.dbscheme text
*.qhelp text
*.html text
*.htm text
*.xhtml text
*.xhtm text
*.js text
*.mjs text
*.ts text
*.json text
*.yml text
*.yaml text
*.c text
*.cpp text
*.h text
*.hpp text
*.md text
*.stats text
*.xml text
*.sh text
*.pl text
*.java text
*.cs text
*.py text
*.lua text
*.expected text

# Explicitly set a bunch of known extensions to binary, because Git < 2.10 will treat
# `* text=auto eol=lf` as `* text eol=lf`
*.png -text
*.jpg -text
*.jpeg -text
*.gif -text
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
# qltest projects and artifacts
*/ql/test/**/*.testproj
*/ql/test/**/*.actual
/.vs/slnx.sqlite
/.vs/ql/v15/Browse.VC.opendb
/.vs/ql/v15/Browse.VC.db
/.vs/ProjectSettings.json

1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/csharp/ @Semmle/cs
/java/ @Semmle/java
/javascript/ @Semmle/js
20 changes: 20 additions & 0 deletions change-notes/1.19/analysis-cpp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Improvements to C/C++ analysis

## General improvements

## New queries

| **Query** | **Tags** | **Purpose** |
|-----------------------------|-----------|--------------------------------------------------------------------|
| *@name of query (Query ID)* | *Tags* |*Aim of the new query and whether it is enabled by default or not* |

## Changes to existing queries

| **Query** | **Expected impact** | **Change** |
|----------------------------|------------------------|------------------------------------------------------------------|
| Resource not released in destructor | Fewer false positive results | Placement new is now excluded from the query. |


## Changes to QL libraries

* Added a hash consing library for structural comparison of expressions.
18 changes: 14 additions & 4 deletions change-notes/1.19/analysis-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@

## General improvements

* Modelling of taint flow through array operations has been improved. This may give additional results for the security queries.

* Support for popular libraries has been improved. Consequently, queries may produce more results on code bases that use the following features:
- file system access, for example through [fs-extra](https://github.com/jprichardson/node-fs-extra) or [globby](https://www.npmjs.com/package/globby)


## New queries

| **Query** | **Tags** | **Purpose** |
|-----------------------------|-----------|--------------------------------------------------------------------|
| *@name of query (Query ID)* | *Tags* |*Aim of the new query and whether it is enabled by default or not* |
| **Query** | **Tags** | **Purpose** |
|-----------------------------------------------|------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Enabling Node.js integration for Electron web content renderers (`js/enabling-electron-renderer-node-integration`) | security, frameworks/electron, external/cwe/cwe-094 | Highlights Electron web content renderer preferences with Node.js integration enabled, indicating a violation of [CWE-94](https://cwe.mitre.org/data/definitions/94.html). Results are not shown on LGTM by default. |
| Stored cross-site scripting (`js/stored-xss`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights uncontrolled stored values flowing into HTML content, indicating a violation of [CWE-079](https://cwe.mitre.org/data/definitions/79.html). Results shown on LGTM by default. |
| Replacement of a substring with itself (`js/identity-replacement`) | correctness, security, external/cwe/cwe-116 | Highlights string replacements that replace a string with itself, which usually indicates a mistake. Results shown on LGTM by default. |

## Changes to existing queries

| **Query** | **Expected impact** | **Change** |
|--------------------------------|----------------------------|----------------------------------------------|
| Regular expression injection | Fewer false-positive results | This rule now identifies calls to `String.prototype.search` with more precision. |

| Unbound event handler receiver | Fewer false-positive results | This rule now recognizes additional ways class methods can be bound. |
| Remote property injection | Fewer results | The precision of this rule has been revised to "medium". Results are no longer shown on LGTM by default. |
| Missing CSRF middleware | Fewer false-positive results | This rule now recognizes additional CSRF protection middlewares. |

## Changes to QL libraries
5 changes: 5 additions & 0 deletions config/identical-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@
"C++ SSA SSAConstruction": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll"
],
"C++ IR ValueNumber": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/ValueNumbering.qll"
]
}
26 changes: 13 additions & 13 deletions cpp/config/suites/security/cwe-120
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
+ semmlecode-cpp-queries/Security/CWE/CWE-120/UnboundedWrite.ql: /CWE/CWE-120
@name Unbounded write (CWE-120)
+ semmlecode-cpp-queries/Security/CWE/CWE-120/BadlyBoundedWrite.ql: /CWE/CWE-120
@name Badly bounded write (CWE-120)
+ semmlecode-cpp-queries/Security/CWE/CWE-120/OverrunWrite.ql: /CWE/CWE-120
@name Potentially overrunning write (CWE-120)
+ semmlecode-cpp-queries/Security/CWE/CWE-120/OverrunWriteFloat.ql: /CWE/CWE-120
@name Potentially overrunning write with float to string conversion (CWE-120)
+ semmlecode-cpp-queries/Best Practices/Likely Errors/OffsetUseBeforeRangeCheck.ql: /CWE/CWE-120
@name Array offset used before range check (CWE-120)
+ semmlecode-cpp-queries/Likely Bugs/Memory Management/UnsafeUseOfStrcat.ql: /CWE/CWE-120
@name Potentially unsafe use of strcat (CWE-120)
# CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
+ semmlecode-cpp-queries/Security/CWE/CWE-120/UnboundedWrite.ql: /CWE/CWE-120
@name Unbounded write (CWE-120)
+ semmlecode-cpp-queries/Security/CWE/CWE-120/BadlyBoundedWrite.ql: /CWE/CWE-120
@name Badly bounded write (CWE-120)
+ semmlecode-cpp-queries/Security/CWE/CWE-120/OverrunWrite.ql: /CWE/CWE-120
@name Potentially overrunning write (CWE-120)
+ semmlecode-cpp-queries/Security/CWE/CWE-120/OverrunWriteFloat.ql: /CWE/CWE-120
@name Potentially overrunning write with float to string conversion (CWE-120)
+ semmlecode-cpp-queries/Best Practices/Likely Errors/OffsetUseBeforeRangeCheck.ql: /CWE/CWE-120
@name Array offset used before range check (CWE-120)
+ semmlecode-cpp-queries/Likely Bugs/Memory Management/UnsafeUseOfStrcat.ql: /CWE/CWE-120
@name Potentially unsafe use of strcat (CWE-120)
6 changes: 3 additions & 3 deletions cpp/config/suites/security/cwe-121
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# CWE-121: Stack-based Buffer Overflow
+ semmlecode-cpp-queries/Security/CWE/CWE-121/UnterminatedVarargsCall.ql: /CWE/CWE-121
@name Unterminated variadic call (CWE-121)
# CWE-121: Stack-based Buffer Overflow
+ semmlecode-cpp-queries/Security/CWE/CWE-121/UnterminatedVarargsCall.ql: /CWE/CWE-121
@name Unterminated variadic call (CWE-121)
14 changes: 7 additions & 7 deletions cpp/config/suites/security/cwe-131
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CWE-131: Incorrect Calculation of Buffer Size
+ semmlecode-cpp-queries/Security/CWE/CWE-131/NoSpaceForZeroTerminator.ql: /CWE/CWE-131
@name No space for zero terminator (CWE-131)
+ semmlecode-cpp-queries/Critical/SizeCheck.ql: /CWE/CWE-131
@name Not enough memory allocated for pointer type (CWE-131)
+ semmlecode-cpp-queries/Critical/SizeCheck2.ql: /CWE/CWE-131
@name Not enough memory allocated for array of pointer type (CWE-131)
# CWE-131: Incorrect Calculation of Buffer Size
+ semmlecode-cpp-queries/Security/CWE/CWE-131/NoSpaceForZeroTerminator.ql: /CWE/CWE-131
@name No space for zero terminator (CWE-131)
+ semmlecode-cpp-queries/Critical/SizeCheck.ql: /CWE/CWE-131
@name Not enough memory allocated for pointer type (CWE-131)
+ semmlecode-cpp-queries/Critical/SizeCheck2.ql: /CWE/CWE-131
@name Not enough memory allocated for array of pointer type (CWE-131)
26 changes: 13 additions & 13 deletions cpp/config/suites/security/cwe-134
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# CWE-134: Uncontrolled Format String
+ semmlecode-cpp-queries/Likely Bugs/Format/NonConstantFormat.ql: /CWE/CWE-134
@name Non-constant format string (CWE-134)
# This one runs out of memory. See ODASA-608.
#+ semmlecode-cpp-queries/PointsTo/TaintedFormatStrings.ql: /CWE/CWE-134
+ semmlecode-cpp-queries/Likely Bugs/Format/WrongNumberOfFormatArguments.ql: /CWE/CWE-134
@name Wrong number of arguments to formatting function (CWE-134)
+ semmlecode-cpp-queries/Likely Bugs/Format/WrongTypeFormatArguments.ql: /CWE/CWE-134
@name Wrong type of arguments to formatting function (CWE-134)
+ semmlecode-cpp-queries/Security/CWE/CWE-134/UncontrolledFormatString.ql: /CWE/CWE-134
@name Uncontrolled format string (CWE-134)
+ semmlecode-cpp-queries/Security/CWE/CWE-134/UncontrolledFormatStringThroughGlobalVar.ql: /CWE/CWE-134
@name Uncontrolled format string (through global variable) (CWE-134)
# CWE-134: Uncontrolled Format String
+ semmlecode-cpp-queries/Likely Bugs/Format/NonConstantFormat.ql: /CWE/CWE-134
@name Non-constant format string (CWE-134)
# This one runs out of memory. See ODASA-608.
#+ semmlecode-cpp-queries/PointsTo/TaintedFormatStrings.ql: /CWE/CWE-134
+ semmlecode-cpp-queries/Likely Bugs/Format/WrongNumberOfFormatArguments.ql: /CWE/CWE-134
@name Wrong number of arguments to formatting function (CWE-134)
+ semmlecode-cpp-queries/Likely Bugs/Format/WrongTypeFormatArguments.ql: /CWE/CWE-134
@name Wrong type of arguments to formatting function (CWE-134)
+ semmlecode-cpp-queries/Security/CWE/CWE-134/UncontrolledFormatString.ql: /CWE/CWE-134
@name Uncontrolled format string (CWE-134)
+ semmlecode-cpp-queries/Security/CWE/CWE-134/UncontrolledFormatStringThroughGlobalVar.ql: /CWE/CWE-134
@name Uncontrolled format string (through global variable) (CWE-134)
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// an include declaration just adds one source dependency, it does not automatically
// add a dependency from this file to all the declarations in stdio.h
#include <stdio.h>
#include <myfile.h> // contains non-static global myfile_err
extern int myfile_err; // this external declaration adds a dependency on myfile.h
class C {
public:
C() {
// one dependency for printf:
printf("Hello world!");
// one dependency for FILE type, and one for NULL macro:
FILE fp = NULL;
}
};
// an include declaration just adds one source dependency, it does not automatically
// add a dependency from this file to all the declarations in stdio.h
#include <stdio.h>
#include <myfile.h> // contains non-static global myfile_err

extern int myfile_err; // this external declaration adds a dependency on myfile.h

class C {
public:
C() {
// one dependency for printf:
printf("Hello world!");
// one dependency for FILE type, and one for NULL macro:
FILE fp = NULL;
}
};

Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
//This struct contains 30 fields.
struct MyParticle {
bool isActive;
int priority;
float x, y, z;
float dx, dy, dz;
float ddx, ddy, ddz;
bool isCollider;
int age, maxAge;
float size1, size2;
bool hasColor;
unsigned char r1, g1, b1, a1;
unsigned char r2, g2, b2, a2;
class texture *tex;
float u1, v1, u2, v2;
};
//This struct contains 30 fields.
struct MyParticle {
bool isActive;
int priority;

float x, y, z;
float dx, dy, dz;
float ddx, ddy, ddz;
bool isCollider;

int age, maxAge;
float size1, size2;

bool hasColor;
unsigned char r1, g1, b1, a1;
unsigned char r2, g2, b2, a2;

class texture *tex;
float u1, v1, u2, v2;
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// this example has 15 parameters.
void fillRect(int x, int y, int w, int h,
int r1, int g1, int b1, int a1,
int r2, int g2, int b2, int a2,
gradient_type grad, unsigned int flags, bool border)
{
// ...
}
// this example has 15 parameters.
void fillRect(int x, int y, int w, int h,
int r1, int g1, int b1, int a1,
int r2, int g2, int b2, int a2,
gradient_type grad, unsigned int flags, bool border)
{
// ...
}
24 changes: 12 additions & 12 deletions cpp/ql/src/Best Practices/ComplexCondition.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//This condition is too complex and can be improved by using local variables
bool accept_message =
(message_type == CONNECT && _state != CONNECTED) ||
(message_type == DISCONNECT && _state == CONNECTED) ||
(message_type == DATA && _state == CONNECTED);
//This condition is acceptable, as all the logical operators are of the same type (&&)
bool valid_connect =
message_type == CONNECT &&
_state != CONNECTED &&
time_since_prev_connect > MAX_CONNECT_INTERVAL &&
message_length <= MAX_PACKET_SIZE &&
//This condition is too complex and can be improved by using local variables
bool accept_message =
(message_type == CONNECT && _state != CONNECTED) ||
(message_type == DISCONNECT && _state == CONNECTED) ||
(message_type == DATA && _state == CONNECTED);

//This condition is acceptable, as all the logical operators are of the same type (&&)
bool valid_connect =
message_type == CONNECT &&
_state != CONNECTED &&
time_since_prev_connect > MAX_CONNECT_INTERVAL &&
message_length <= MAX_PACKET_SIZE &&
checksum(message) == get_checksum_field(message);
12 changes: 6 additions & 6 deletions cpp/ql/src/Best Practices/Hiding/DeclarationHidesParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
void f(int i) {
for (int i = 0; i < 10; ++i) { //the loop variable hides the parameter to f()
...
}
}
void f(int i) {
for (int i = 0; i < 10; ++i) { //the loop variable hides the parameter to f()
...
}
}

24 changes: 12 additions & 12 deletions cpp/ql/src/Best Practices/Hiding/DeclarationHidesVariable.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
void f() {
int i = 10;
for (int i = 0; i < 10; i++) { //the loop counter hides the variable
...
}
{
int i = 12; //this variable hides the variable in the outer block
...
}
}
void f() {
int i = 10;

for (int i = 0; i < 10; i++) { //the loop counter hides the variable
...
}

{
int i = 12; //this variable hides the variable in the outer block
...
}
}
Loading