Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
27a83e6
C++: add RelationalOpcode and RelationalInstruction
Sep 13, 2018
4e1a37c
C++: add isStrict to RelationalInstruction
Sep 14, 2018
d7e630b
C++: Add IR-based port of Guards library
Sep 14, 2018
ad8f30d
C++: accept test output and add IR guards tests
Sep 14, 2018
0273b20
C++: make internal classes private
Sep 14, 2018
b5cd48d
C++: comments on new classes and predicates
Sep 14, 2018
d6cea1b
C++: Add class and predicates to other IR stages
Sep 14, 2018
e40ce91
C++: document new IR class and predicates
Sep 14, 2018
755e21d
C++: improve conversion handling in IRGuards.qll
Sep 18, 2018
4c94144
C++: remove abstract classes in IR
Sep 18, 2018
cc97cf9
C++: add isReachableFromFunctionEntry
Sep 18, 2018
9011e13
C++: handle conversions in IR to AST translation
Sep 20, 2018
e2d24a2
C++: fix comment
Sep 20, 2018
42fc28b
JS: add ad hoc whitelist checks as sanitizers
Sep 24, 2018
ce11b53
JS: recognize Express headers as RequestInputAccess
asger-semmle Sep 21, 2018
e78a4e9
JS: update output from other Express tests
asger-semmle Sep 21, 2018
52061b3
JS: address review comments: improve regex, limit sanitizer usage
Sep 26, 2018
097a281
JS: change notes for AdHocWhitelistCheckSanitizer
Sep 26, 2018
a47b1dc
JS: recognize Express header access with dynamic name
asger-semmle Sep 26, 2018
057c3a9
JS: update other Express test outputs
asger-semmle Sep 26, 2018
e2ccd57
.gitignore everything under .vs in repo root dir
jbj Sep 26, 2018
a93939b
Merge pull request #230 from esben-semmle/js/ad-hoc-whitelisting
semmle-qlci Sep 26, 2018
26c1397
CPP/CSharp/Javascript: Clean up QLDoc and bring the different XML.qll…
aschackmull Sep 26, 2018
9198f5b
CPP/CSharp/Java/Javascript: Use concat in XMLParent.allCharactersStri…
aschackmull Sep 26, 2018
c5d08ff
Don't .gitignore .vs/VSWorkspaceSettings.json
jbj Sep 26, 2018
c36e7f0
Merge pull request #231 from asger-semmle/express-headers
semmle-qlci Sep 26, 2018
df4bd36
Merge pull request #236 from aschackmull/xml-qll/use-concat
semmle-qlci Sep 27, 2018
b3dbb44
Java: Improve performance of TypeFlow.
aschackmull Sep 27, 2018
87271fb
Merge pull request #234 from jbj/gitignore-vs
adityasharad Sep 27, 2018
f323fa1
C++: test changes from previous commit
Sep 27, 2018
b6cc6a3
C++: Fix BinaryLogicalOperators always being guards
Sep 27, 2018
93732d8
C++: Combine IR guard tests into one ql file
Sep 27, 2018
f5bd737
Version: Fix C# and JavaScript Eclipse plugins for 1.18.
adityasharad Sep 28, 2018
b8b41a4
Merge pull request #248 from adityasharad/fix/eclipse-versions-1.18
Sep 28, 2018
1c71a85
Version: Bump to 1.18.1 dev.
adityasharad Sep 28, 2018
16004fa
Merge pull request #197 from rdmarsh2/rdmarsh/cpp/ir-guards
jbj Sep 28, 2018
89183bd
Merge pull request #244 from aschackmull/java/typeflow-perf
semmle-qlci Sep 29, 2018
eb987d5
C++: Make `Instruction.toString()` less expensive
dave-bartolomeo Sep 30, 2018
3709195
C++: Fix test expectations after rebase
dave-bartolomeo Sep 30, 2018
9ffdf3b
Merge pull request #254 from dave-bartolomeo/dave/InstructionToString
jbj Oct 1, 2018
8cc7f5c
JavaScript: Update model of `DOMException`.
Oct 1, 2018
828d3cb
Merge pull request #250 from adityasharad/version/1.18.1-dev
nickrolfe Oct 1, 2018
0882eb7
Merge rc/1.18 into master.
adityasharad Oct 1, 2018
7518267
Merge pull request #257 from xiemaisi/js/fix-DOMException-model
Oct 1, 2018
13ef492
Merge pull request #258 from adityasharad/merge/1.18-master-011018
aibaars Oct 1, 2018
337defd
Merge master into next.
adityasharad Oct 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
# 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

# Visual studio temporaries, except a file used by QL4VS
.vs/*
!.vs/VSWorkspaceSettings.json
2 changes: 2 additions & 0 deletions change-notes/1.19/analysis-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

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

* The taint tracking library now recognizes additional sanitization patterns. This may give fewer false-positive 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)

Expand Down
130 changes: 65 additions & 65 deletions cpp/ql/src/semmle/code/cpp/XML.qll
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* A library for working with XML files and their content.
* Provides classes and predicates for working with XML files and their content.
*/

import semmle.code.cpp.Location

/** An XML element that has a location. */
abstract class XMLLocatable extends @xmllocatable {
/** The source location for this element. */
/** Gets the source location for this element. */
Location getLocation() { xmllocations(this,result) }

/**
* Whether this element has the specified location information,
* Holds if this element has the specified location information,
* including file path, start line, start column, end line and end column.
*/
predicate hasLocationInfo(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
Expand All @@ -20,7 +20,7 @@ abstract class XMLLocatable extends @xmllocatable {
)
}

/** A printable representation of this element. */
/** Gets a printable representation of this element. */
abstract string toString();
}

Expand All @@ -30,46 +30,49 @@ abstract class XMLLocatable extends @xmllocatable {
*/
class XMLParent extends @xmlparent {
/**
* A printable representation of this XML parent.
* Gets a printable representation of this XML parent.
* (Intended to be overridden in subclasses.)
*/
abstract string getName();

/** The file to which this XML parent belongs. */
/** Gets the file to which this XML parent belongs. */
XMLFile getFile() { result = this or xmlElements(this,_,_,_,result) }

/** The child element at a specified index of this XML parent. */
/** Gets the child element at a specified index of this XML parent. */
XMLElement getChild(int index) { xmlElements(result, _, this, index, _) }

/** A child element of this XML parent. */
/** Gets a child element of this XML parent. */
XMLElement getAChild() { xmlElements(result,_,this,_,_) }

/** A child element of this XML parent with the given `name`. */
/** Gets a child element of this XML parent with the given `name`. */
XMLElement getAChild(string name) { xmlElements(result,_,this,_,_) and result.hasName(name) }

/** A comment that is a child of this XML parent. */
/** Gets a comment that is a child of this XML parent. */
XMLComment getAComment() { xmlComments(result,_,this,_) }

/** A character sequence that is a child of this XML parent. */
/** Gets a character sequence that is a child of this XML parent. */
XMLCharacters getACharactersSet() { xmlChars(result,_,this,_,_,_) }

/** The depth in the tree. (Overridden in XMLElement.) */
/** Gets the depth in the tree. (Overridden in XMLElement.) */
int getDepth() { result = 0 }

/** The number of child XML elements of this XML parent. */
/** Gets the number of child XML elements of this XML parent. */
int getNumberOfChildren() {
result = count(XMLElement e | xmlElements(e,_,this,_,_))
}

/** The number of places in the body of this XML parent where text occurs. */
/** Gets the number of places in the body of this XML parent where text occurs. */
int getNumberOfCharacterSets() {
result = count(int pos | xmlChars(_,_,this,pos,_,_))
}

/**
* DEPRECATED: Internal.
*
* Append the character sequences of this XML parent from left to right, separated by a space,
* up to a specified (zero-based) index.
*/
deprecated
string charsSetUpTo(int n) {
(n = 0 and xmlChars(_,result,this,0,_,_)) or
(n > 0 and exists(string chars | xmlChars(_,chars,this,n,_,_) |
Expand All @@ -78,18 +81,15 @@ class XMLParent extends @xmlparent {

/** Append all the character sequences of this XML parent from left to right, separated by a space. */
string allCharactersString() {
exists(int n | n = this.getNumberOfCharacterSets() |
(n = 0 and result = "") or
(n > 0 and result = this.charsSetUpTo(n-1))
)
result = concat(string chars, int pos | xmlChars(_, chars, this, pos, _, _) | chars, " " order by pos)
}

/** The text value contained in this XML parent. */
/** Gets the text value contained in this XML parent. */
string getTextValue() {
result = allCharactersString()
}

/** A printable representation of this XML parent. */
/** Gets a printable representation of this XML parent. */
string toString() { result = this.getName() }
}

Expand All @@ -99,54 +99,54 @@ class XMLFile extends XMLParent, File {
xmlEncoding(this,_)
}

/** A printable representation of this XML file. */
/** Gets a printable representation of this XML file. */
override
string toString() { result = XMLParent.super.toString() }

/** The name of this XML file. */
/** Gets the name of this XML file. */
override
string getName() { files(this,result,_,_,_) }

/** The path of this XML file. */
/** Gets the path of this XML file. */
string getPath() { files(this,_,result,_,_) }

/** The path of the folder that contains this XML file. */
/** Gets the path of the folder that contains this XML file. */
string getFolder() {
result = this.getPath().substring(0, this.getPath().length()-this.getName().length())
}

/** The encoding of this XML file. */
/** Gets the encoding of this XML file. */
string getEncoding() { xmlEncoding(this,result) }

/** The XML file itself. */
/** Gets the XML file itself. */
override
XMLFile getFile() { result = this }

/** A top-most element in an XML file. */
/** Gets a top-most element in an XML file. */
XMLElement getARootElement() { result = this.getAChild() }

/** A DTD associated with this XML file. */
/** Gets a DTD associated with this XML file. */
XMLDTD getADTD() { xmlDTDs(result,_,_,_,this) }
}

/** A "Document Type Definition" of an XML file. */
class XMLDTD extends @xmldtd {
/** The name of the root element of this DTD. */
/** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this,result,_,_,_) }

/** The public ID of this DTD. */
/** Gets the public ID of this DTD. */
string getPublicId() { xmlDTDs(this,_,result,_,_) }

/** The system ID of this DTD. */
/** Gets the system ID of this DTD. */
string getSystemId() { xmlDTDs(this,_,_,result,_) }

/** Whether this DTD is public. */
/** Holds if this DTD is public. */
predicate isPublic() { not xmlDTDs(this,_,"",_,_) }

/** The parent of this DTD. */
/** Gets the parent of this DTD. */
XMLParent getParent() { xmlDTDs(this,_,_,_,result) }

/** A printable representation of this DTD. */
/** Gets a printable representation of this DTD. */
string toString() {
(this.isPublic() and result = this.getRoot() + " PUBLIC '" +
this.getPublicId() + "' '" +
Expand All @@ -159,92 +159,92 @@ class XMLDTD extends @xmldtd {

/** An XML tag in an XML file. */
class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
/** Whether this XML element has the given `name`. */
/** Holds if this XML element has the given `name`. */
predicate hasName(string name) { name = getName() }

/** The name of this XML element. */
/** Gets the name of this XML element. */
override
string getName() { xmlElements(this,result,_,_,_) }

/** The XML file in which this XML element occurs. */
/** Gets the XML file in which this XML element occurs. */
override
XMLFile getFile() { xmlElements(this,_,_,_,result) }

/** The parent of this XML element. */
/** Gets the parent of this XML element. */
XMLParent getParent() { xmlElements(this,_,result,_,_) }

/** The index of this XML element among its parent's children. */
/** Gets the index of this XML element among its parent's children. */
int getIndex() { xmlElements(this, _, _, result, _) }

/** Whether this XML element has a namespace. */
/** Holds if this XML element has a namespace. */
predicate hasNamespace() { xmlHasNs(this,_,_) }

/** The namespace of this XML element, if any. */
/** Gets the namespace of this XML element, if any. */
XMLNamespace getNamespace() { xmlHasNs(this,result,_) }

/** The index of this XML element among its parent's children. */
/** Gets the index of this XML element among its parent's children. */
int getElementPositionIndex() { xmlElements(this,_,_,result,_) }

/** The depth of this element within the XML file tree structure. */
/** Gets the depth of this element within the XML file tree structure. */
override
int getDepth() { result = this.getParent().getDepth() + 1 }

/** An XML attribute of this XML element. */
/** Gets an XML attribute of this XML element. */
XMLAttribute getAnAttribute() { result.getElement() = this }

/** The attribute with the specified `name`, if any. */
/** Gets the attribute with the specified `name`, if any. */
XMLAttribute getAttribute(string name) {
result.getElement() = this and result.getName() = name
}

/** Whether this XML element has an attribute with the specified `name`. */
/** Holds if this XML element has an attribute with the specified `name`. */
predicate hasAttribute(string name) {
exists(XMLAttribute a| a = this.getAttribute(name))
}

/** The value of the attribute with the specified `name`, if any. */
/** Gets the value of the attribute with the specified `name`, if any. */
string getAttributeValue(string name) {
result = this.getAttribute(name).getValue()
}

/** A printable representation of this XML element. */
/** Gets a printable representation of this XML element. */
override
string toString() { result = XMLParent.super.toString() }
}

/** An attribute that occurs inside an XML element. */
class XMLAttribute extends @xmlattribute, XMLLocatable {
/** The name of this attribute. */
/** Gets the name of this attribute. */
string getName() { xmlAttrs(this,_,result,_,_,_) }

/** The XML element to which this attribute belongs. */
/** Gets the XML element to which this attribute belongs. */
XMLElement getElement() { xmlAttrs(this,result,_,_,_,_) }

/** Whether this attribute has a namespace. */
/** Holds if this attribute has a namespace. */
predicate hasNamespace() { xmlHasNs(this,_,_) }

/** The namespace of this attribute, if any. */
/** Gets the namespace of this attribute, if any. */
XMLNamespace getNamespace() { xmlHasNs(this,result,_) }

/** The value of this attribute. */
/** Gets the value of this attribute. */
string getValue() { xmlAttrs(this,_,_,result,_,_) }

/** A printable representation of this XML attribute. */
/** Gets a printable representation of this XML attribute. */
override string toString() { result = this.getName() + "=" + this.getValue() }
}

/** A namespace used in an XML file */
class XMLNamespace extends @xmlnamespace {
/** The prefix of this namespace. */
/** Gets the prefix of this namespace. */
string getPrefix() { xmlNs(this,result,_,_) }

/** The URI of this namespace. */
/** Gets the URI of this namespace. */
string getURI() { xmlNs(this,_,result,_) }

/** Whether this namespace has no prefix. */
/** Holds if this namespace has no prefix. */
predicate isDefault() { this.getPrefix() = "" }

/** A printable representation of this XML namespace. */
/** Gets a printable representation of this XML namespace. */
string toString() {
(this.isDefault() and result = this.getURI()) or
(not this.isDefault() and result = this.getPrefix() + ":" + this.getURI())
Expand All @@ -253,13 +253,13 @@ class XMLNamespace extends @xmlnamespace {

/** A comment of the form `<!-- ... -->` is an XML comment. */
class XMLComment extends @xmlcomment, XMLLocatable {
/** The text content of this XML comment. */
/** Gets the text content of this XML comment. */
string getText() { xmlComments(this,result,_,_) }

/** The parent of this XML comment. */
/** Gets the parent of this XML comment. */
XMLParent getParent() { xmlComments(this,_,result,_) }

/** A printable representation of this XML comment. */
/** Gets a printable representation of this XML comment. */
override string toString() { result = this.getText() }
}

Expand All @@ -268,15 +268,15 @@ class XMLComment extends @xmlcomment, XMLLocatable {
* closing tags of an XML element, excluding other elements.
*/
class XMLCharacters extends @xmlcharacters, XMLLocatable {
/** The content of this character sequence. */
/** Gets the content of this character sequence. */
string getCharacters() { xmlChars(this,result,_,_,_,_) }

/** The parent of this character sequence. */
/** Gets the parent of this character sequence. */
XMLParent getParent() { xmlChars(this,_,result,_,_,_) }

/** Whether this character sequence is CDATA. */
/** Holds if this character sequence is CDATA. */
predicate isCDATA() { xmlChars(this,_,_,_,1,_) }

/** A printable representation of this XML character sequence. */
/** Gets a printable representation of this XML character sequence. */
override string toString() { result = this.getCharacters() }
}
Loading