Merge pull request #10096 from erik-krogh/acronyms-part1

make acronyms camelcase
This commit is contained in:
Erik Krogh Kristensen
2022-08-24 09:33:53 +02:00
committed by GitHub
108 changed files with 779 additions and 491 deletions

View File

@@ -1,5 +1,5 @@
--- ---
category: deprecated category: deprecated
--- ---
* Classes/predicates that had upper-case acronym XML in their name have been renamed to Xml to follow our style-guide. * Many classes/predicates/modules with upper-case acronyms in their name have been renamed to follow our style-guide.
The old name still exists as a deprecated alias. The old name still exists as a deprecated alias.

View File

@@ -132,7 +132,10 @@ class XmlFile extends XmlParent, File {
XmlElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XmlDTD getADTD() { xmlDTDs(result, _, _, _, this) } XmlDtd getADtd() { xmlDTDs(result, _, _, _, this) }
/** DEPRECATED: Alias for getADtd */
deprecated XmlDtd getADTD() { result = this.getADtd() }
} }
/** DEPRECATED: Alias for XmlFile */ /** DEPRECATED: Alias for XmlFile */
@@ -149,7 +152,7 @@ deprecated class XMLFile = XmlFile;
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XmlDTD extends XmlLocatable, @xmldtd { class XmlDtd extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -174,8 +177,8 @@ class XmlDTD extends XmlLocatable, @xmldtd {
} }
} }
/** DEPRECATED: Alias for XmlDTD */ /** DEPRECATED: Alias for XmlDtd */
deprecated class XMLDTD = XmlDTD; deprecated class XMLDTD = XmlDtd;
/** /**
* An XML element in an XML file. * An XML element in an XML file.
@@ -282,15 +285,18 @@ class XmlNamespace extends XmlLocatable, @xmlnamespace {
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
/** Gets the URI of this namespace. */ /** Gets the URI of this namespace. */
string getURI() { xmlNs(this, _, result, _) } string getUri() { xmlNs(this, _, result, _) }
/** DEPRECATED: Alias for getUri */
deprecated string getURI() { result = this.getUri() }
/** Holds if this namespace has no prefix. */ /** Holds if this namespace has no prefix. */
predicate isDefault() { this.getPrefix() = "" } predicate isDefault() { this.getPrefix() = "" }
override string toString() { override string toString() {
this.isDefault() and result = this.getURI() this.isDefault() and result = this.getUri()
or or
not this.isDefault() and result = this.getPrefix() + ":" + this.getURI() not this.isDefault() and result = this.getPrefix() + ":" + this.getUri()
} }
} }

View File

@@ -3,7 +3,7 @@ import semmle.code.cpp.ir.internal.Overlap
private import semmle.code.cpp.ir.internal.IRCppLanguage as Language private import semmle.code.cpp.ir.internal.IRCppLanguage as Language
private import semmle.code.cpp.Print private import semmle.code.cpp.Print
private import semmle.code.cpp.ir.implementation.unaliased_ssa.IR private import semmle.code.cpp.ir.implementation.unaliased_ssa.IR
private import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSAConstruction as OldSSA private import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSAConstruction as OldSsa
private import semmle.code.cpp.ir.internal.IntegerConstant as Ints private import semmle.code.cpp.ir.internal.IntegerConstant as Ints
private import semmle.code.cpp.ir.internal.IntegerInterval as Interval private import semmle.code.cpp.ir.internal.IntegerInterval as Interval
private import semmle.code.cpp.ir.implementation.internal.OperandTag private import semmle.code.cpp.ir.implementation.internal.OperandTag
@@ -572,7 +572,7 @@ private Overlap getVariableMemoryLocationOverlap(
* Holds if the def/use information for the result of `instr` can be reused from the previous * Holds if the def/use information for the result of `instr` can be reused from the previous
* iteration of the IR. * iteration of the IR.
*/ */
predicate canReuseSsaForOldResult(Instruction instr) { OldSSA::canReuseSsaForMemoryResult(instr) } predicate canReuseSsaForOldResult(Instruction instr) { OldSsa::canReuseSsaForMemoryResult(instr) }
/** DEPRECATED: Alias for canReuseSsaForOldResult */ /** DEPRECATED: Alias for canReuseSsaForOldResult */
deprecated predicate canReuseSSAForOldResult = canReuseSsaForOldResult/1; deprecated predicate canReuseSSAForOldResult = canReuseSsaForOldResult/1;

View File

@@ -5,8 +5,8 @@ private import Imports::OperandTag
private import Imports::Overlap private import Imports::Overlap
private import Imports::TInstruction private import Imports::TInstruction
private import Imports::RawIR as RawIR private import Imports::RawIR as RawIR
private import SSAInstructions private import SsaInstructions
private import SSAOperands private import SsaOperands
private import NewIR private import NewIR
private class OldBlock = Reachability::ReachableBlock; private class OldBlock = Reachability::ReachableBlock;

View File

@@ -2,7 +2,14 @@ import semmle.code.cpp.ir.implementation.unaliased_ssa.IR as OldIR
import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.reachability.ReachableBlock as Reachability import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.reachability.ReachableBlock as Reachability
import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.reachability.Dominance as Dominance import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.reachability.Dominance as Dominance
import semmle.code.cpp.ir.implementation.aliased_ssa.IR as NewIR import semmle.code.cpp.ir.implementation.aliased_ssa.IR as NewIR
import semmle.code.cpp.ir.implementation.internal.TInstruction::AliasedSsaInstructions as SSAInstructions import semmle.code.cpp.ir.implementation.internal.TInstruction::AliasedSsaInstructions as SsaInstructions
/** DEPRECATED: Alias for SsaInstructions */
deprecated module SSAInstructions = SsaInstructions;
import semmle.code.cpp.ir.internal.IRCppLanguage as Language import semmle.code.cpp.ir.internal.IRCppLanguage as Language
import AliasedSSA as Alias import AliasedSSA as Alias
import semmle.code.cpp.ir.implementation.internal.TOperand::AliasedSsaOperands as SSAOperands import semmle.code.cpp.ir.implementation.internal.TOperand::AliasedSsaOperands as SsaOperands
/** DEPRECATED: Alias for SsaOperands */
deprecated module SSAOperands = SsaOperands;

View File

@@ -29,15 +29,15 @@ newtype TInstruction =
UnaliasedSsa::SSA::hasUnreachedInstruction(irFunc) UnaliasedSsa::SSA::hasUnreachedInstruction(irFunc)
} or } or
TAliasedSsaPhiInstruction( TAliasedSsaPhiInstruction(
TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation TRawInstruction blockStartInstr, AliasedSsa::SSA::MemoryLocation memoryLocation
) { ) {
AliasedSSA::SSA::hasPhiInstruction(blockStartInstr, memoryLocation) AliasedSsa::SSA::hasPhiInstruction(blockStartInstr, memoryLocation)
} or } or
TAliasedSsaChiInstruction(TRawInstruction primaryInstruction) { TAliasedSsaChiInstruction(TRawInstruction primaryInstruction) {
AliasedSSA::SSA::hasChiInstruction(primaryInstruction) AliasedSsa::SSA::hasChiInstruction(primaryInstruction)
} or } or
TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) { TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) {
AliasedSSA::SSA::hasUnreachedInstruction(irFunc) AliasedSsa::SSA::hasUnreachedInstruction(irFunc)
} }
/** /**
@@ -83,7 +83,7 @@ module AliasedSsaInstructions {
class TPhiInstruction = TAliasedSsaPhiInstruction or TUnaliasedSsaPhiInstruction; class TPhiInstruction = TAliasedSsaPhiInstruction or TUnaliasedSsaPhiInstruction;
TPhiInstruction phiInstruction( TPhiInstruction phiInstruction(
TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation TRawInstruction blockStartInstr, AliasedSsa::SSA::MemoryLocation memoryLocation
) { ) {
result = TAliasedSsaPhiInstruction(blockStartInstr, memoryLocation) result = TAliasedSsaPhiInstruction(blockStartInstr, memoryLocation)
} }

View File

@@ -1,4 +1,7 @@
import semmle.code.cpp.ir.internal.IRCppLanguage as Language import semmle.code.cpp.ir.internal.IRCppLanguage as Language
import semmle.code.cpp.ir.implementation.raw.internal.IRConstruction as IRConstruction import semmle.code.cpp.ir.implementation.raw.internal.IRConstruction as IRConstruction
import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSsa import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSsa
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSAConstruction as AliasedSSA import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSAConstruction as AliasedSsa
/** DEPRECATED: Alias for AliasedSsa */
deprecated module AliasedSSA = AliasedSsa;

View File

@@ -5,8 +5,8 @@ private import Imports::OperandTag
private import Imports::Overlap private import Imports::Overlap
private import Imports::TInstruction private import Imports::TInstruction
private import Imports::RawIR as RawIR private import Imports::RawIR as RawIR
private import SSAInstructions private import SsaInstructions
private import SSAOperands private import SsaOperands
private import NewIR private import NewIR
private class OldBlock = Reachability::ReachableBlock; private class OldBlock = Reachability::ReachableBlock;

View File

@@ -3,7 +3,14 @@ import semmle.code.cpp.ir.implementation.raw.internal.reachability.ReachableBloc
import semmle.code.cpp.ir.implementation.raw.internal.reachability.Dominance as Dominance import semmle.code.cpp.ir.implementation.raw.internal.reachability.Dominance as Dominance
import semmle.code.cpp.ir.implementation.unaliased_ssa.IR as NewIR import semmle.code.cpp.ir.implementation.unaliased_ssa.IR as NewIR
import semmle.code.cpp.ir.implementation.raw.internal.IRConstruction as RawStage import semmle.code.cpp.ir.implementation.raw.internal.IRConstruction as RawStage
import semmle.code.cpp.ir.implementation.internal.TInstruction::UnaliasedSsaInstructions as SSAInstructions import semmle.code.cpp.ir.implementation.internal.TInstruction::UnaliasedSsaInstructions as SsaInstructions
/** DEPRECATED: Alias for SsaInstructions */
deprecated module SSAInstructions = SsaInstructions;
import semmle.code.cpp.ir.internal.IRCppLanguage as Language import semmle.code.cpp.ir.internal.IRCppLanguage as Language
import SimpleSSA as Alias import SimpleSSA as Alias
import semmle.code.cpp.ir.implementation.internal.TOperand::UnaliasedSsaOperands as SSAOperands import semmle.code.cpp.ir.implementation.internal.TOperand::UnaliasedSsaOperands as SsaOperands
/** DEPRECATED: Alias for SsaOperands */
deprecated module SSAOperands = SsaOperands;

View File

@@ -21,7 +21,9 @@ class UntrustedExternalApiDataNode extends ExternalApiDataNode {
/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ /** DEPRECATED: Alias for UntrustedExternalApiDataNode */
deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode;
/** An external API which is used with untrusted data. */
private newtype TExternalApi = private newtype TExternalApi =
/** An untrusted API method `m` where untrusted data is passed at `index`. */
TExternalApiParameter(Function f, int index) { TExternalApiParameter(Function f, int index) {
exists(UntrustedExternalApiDataNode n | exists(UntrustedExternalApiDataNode n |
f = n.getExternalFunction() and f = n.getExternalFunction() and

View File

@@ -21,7 +21,9 @@ class UntrustedExternalApiDataNode extends ExternalApiDataNode {
/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ /** DEPRECATED: Alias for UntrustedExternalApiDataNode */
deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode;
/** An external API which is used with untrusted data. */
private newtype TExternalApi = private newtype TExternalApi =
/** An untrusted API method `m` where untrusted data is passed at `index`. */
TExternalApiParameter(Function f, int index) { TExternalApiParameter(Function f, int index) {
exists(UntrustedExternalApiDataNode n | exists(UntrustedExternalApiDataNode n |
f = n.getExternalFunction() and f = n.getExternalFunction() and

View File

@@ -17,8 +17,8 @@ import semmle.code.cpp.dataflow.DataFlow
/** /**
* A call to `SSL_get_verify_result`. * A call to `SSL_get_verify_result`.
*/ */
class SSLGetVerifyResultCall extends FunctionCall { class SslGetVerifyResultCall extends FunctionCall {
SSLGetVerifyResultCall() { getTarget().getName() = "SSL_get_verify_result" } SslGetVerifyResultCall() { getTarget().getName() = "SSL_get_verify_result" }
} }
/** /**
@@ -29,7 +29,7 @@ class VerifyResultConfig extends DataFlow::Configuration {
VerifyResultConfig() { this = "VerifyResultConfig" } VerifyResultConfig() { this = "VerifyResultConfig" }
override predicate isSource(DataFlow::Node source) { override predicate isSource(DataFlow::Node source) {
source.asExpr() instanceof SSLGetVerifyResultCall source.asExpr() instanceof SslGetVerifyResultCall
} }
override predicate isSink(DataFlow::Node sink) { override predicate isSink(DataFlow::Node sink) {

View File

@@ -17,33 +17,33 @@ import semmle.code.cpp.controlflow.IRGuards
/** /**
* A call to `SSL_get_peer_certificate`. * A call to `SSL_get_peer_certificate`.
*/ */
class SSLGetPeerCertificateCall extends FunctionCall { class SslGetPeerCertificateCall extends FunctionCall {
SSLGetPeerCertificateCall() { SslGetPeerCertificateCall() {
getTarget().getName() = "SSL_get_peer_certificate" // SSL_get_peer_certificate(ssl) getTarget().getName() = "SSL_get_peer_certificate" // SSL_get_peer_certificate(ssl)
} }
Expr getSSLArgument() { result = getArgument(0) } Expr getSslArgument() { result = getArgument(0) }
} }
/** /**
* A call to `SSL_get_verify_result`. * A call to `SSL_get_verify_result`.
*/ */
class SSLGetVerifyResultCall extends FunctionCall { class SslGetVerifyResultCall extends FunctionCall {
SSLGetVerifyResultCall() { SslGetVerifyResultCall() {
getTarget().getName() = "SSL_get_verify_result" // SSL_get_peer_certificate(ssl) getTarget().getName() = "SSL_get_verify_result" // SSL_get_peer_certificate(ssl)
} }
Expr getSSLArgument() { result = getArgument(0) } Expr getSslArgument() { result = getArgument(0) }
} }
/** /**
* Holds if the SSL object passed into `SSL_get_peer_certificate` is checked with * Holds if the SSL object passed into `SSL_get_peer_certificate` is checked with
* `SSL_get_verify_result` entering `node`. * `SSL_get_verify_result` entering `node`.
*/ */
predicate resultIsChecked(SSLGetPeerCertificateCall getCertCall, ControlFlowNode node) { predicate resultIsChecked(SslGetPeerCertificateCall getCertCall, ControlFlowNode node) {
exists(Expr ssl, SSLGetVerifyResultCall check | exists(Expr ssl, SslGetVerifyResultCall check |
ssl = globalValueNumber(getCertCall.getSSLArgument()).getAnExpr() and ssl = globalValueNumber(getCertCall.getSslArgument()).getAnExpr() and
ssl = check.getSSLArgument() and ssl = check.getSslArgument() and
node = check node = check
) )
} }
@@ -53,7 +53,7 @@ predicate resultIsChecked(SSLGetPeerCertificateCall getCertCall, ControlFlowNode
* `0` on the edge `node1` to `node2`. * `0` on the edge `node1` to `node2`.
*/ */
predicate certIsZero( predicate certIsZero(
SSLGetPeerCertificateCall getCertCall, ControlFlowNode node1, ControlFlowNode node2 SslGetPeerCertificateCall getCertCall, ControlFlowNode node1, ControlFlowNode node2
) { ) {
exists(Expr cert | cert = globalValueNumber(getCertCall).getAnExpr() | exists(Expr cert | cert = globalValueNumber(getCertCall).getAnExpr() |
exists(GuardCondition guard, Expr zero | exists(GuardCondition guard, Expr zero |
@@ -87,7 +87,7 @@ predicate certIsZero(
* `SSL_get_verify_result` at `node`. Note that this is only computed at the call to * `SSL_get_verify_result` at `node`. Note that this is only computed at the call to
* `SSL_get_peer_certificate` and at the start and end of `BasicBlock`s. * `SSL_get_peer_certificate` and at the start and end of `BasicBlock`s.
*/ */
predicate certNotChecked(SSLGetPeerCertificateCall getCertCall, ControlFlowNode node) { predicate certNotChecked(SslGetPeerCertificateCall getCertCall, ControlFlowNode node) {
// cert is not checked at the call to `SSL_get_peer_certificate` // cert is not checked at the call to `SSL_get_peer_certificate`
node = getCertCall node = getCertCall
or or
@@ -112,7 +112,7 @@ predicate certNotChecked(SSLGetPeerCertificateCall getCertCall, ControlFlowNode
) )
} }
from SSLGetPeerCertificateCall getCertCall, ControlFlowNode node from SslGetPeerCertificateCall getCertCall, ControlFlowNode node
where where
certNotChecked(getCertCall, node) and certNotChecked(getCertCall, node) and
node instanceof Function // (function exit) node instanceof Function // (function exit)

View File

@@ -47,14 +47,17 @@ class EnvData extends SystemData {
/** /**
* Data originating from a call to `mysql_get_client_info()`. * Data originating from a call to `mysql_get_client_info()`.
*/ */
class SQLClientInfo extends SystemData { class SqlClientInfo extends SystemData {
SQLClientInfo() { this.(FunctionCall).getTarget().hasName("mysql_get_client_info") } SqlClientInfo() { this.(FunctionCall).getTarget().hasName("mysql_get_client_info") }
override DataFlow::Node getAnExpr() { result.asConvertedExpr() = this } override DataFlow::Node getAnExpr() { result.asConvertedExpr() = this }
override predicate isSensitive() { any() } override predicate isSensitive() { any() }
} }
/** DEPRECATED: Alias for SqlClientInfo */
deprecated class SQLClientInfo = SqlClientInfo;
private predicate sqlConnectInfo(FunctionCall source, Expr use) { private predicate sqlConnectInfo(FunctionCall source, Expr use) {
( (
source.getTarget().hasName("mysql_connect") or source.getTarget().hasName("mysql_connect") or
@@ -66,14 +69,17 @@ private predicate sqlConnectInfo(FunctionCall source, Expr use) {
/** /**
* Data passed into an SQL connect function. * Data passed into an SQL connect function.
*/ */
class SQLConnectInfo extends SystemData { class SqlConnectInfo extends SystemData {
SQLConnectInfo() { sqlConnectInfo(this, _) } SqlConnectInfo() { sqlConnectInfo(this, _) }
override DataFlow::Node getAnExpr() { sqlConnectInfo(this, result.asConvertedExpr()) } override DataFlow::Node getAnExpr() { sqlConnectInfo(this, result.asConvertedExpr()) }
override predicate isSensitive() { any() } override predicate isSensitive() { any() }
} }
/** DEPRECATED: Alias for SqlConnectInfo */
deprecated class SQLConnectInfo = SqlConnectInfo;
private predicate posixSystemInfo(FunctionCall source, DataFlow::Node use) { private predicate posixSystemInfo(FunctionCall source, DataFlow::Node use) {
// size_t confstr(int name, char *buf, size_t len) // size_t confstr(int name, char *buf, size_t len)
// - various OS / system strings, such as the libc version // - various OS / system strings, such as the libc version

View File

@@ -13,7 +13,7 @@
import cpp import cpp
private import semmle.code.cpp.ir.dataflow.DataFlow::DataFlow as IRDataFlow private import semmle.code.cpp.ir.dataflow.DataFlow::DataFlow as IRDataFlow
private import semmle.code.cpp.dataflow.DataFlow::DataFlow as ASTDataFlow private import semmle.code.cpp.dataflow.DataFlow::DataFlow as AstDataFlow
import TestUtilities.InlineExpectationsTest import TestUtilities.InlineExpectationsTest
class IRFlowTest extends InlineExpectationsTest { class IRFlowTest extends InlineExpectationsTest {
@@ -49,11 +49,11 @@ class AstFlowTest extends InlineExpectationsTest {
override predicate hasActualResult(Location location, string element, string tag, string value) { override predicate hasActualResult(Location location, string element, string tag, string value) {
exists( exists(
ASTDataFlow::Node source, ASTDataFlow::Node sink, ASTDataFlow::Configuration conf, int n AstDataFlow::Node source, AstDataFlow::Node sink, AstDataFlow::Configuration conf, int n
| |
tag = "ast" and tag = "ast" and
conf.hasFlow(source, sink) and conf.hasFlow(source, sink) and
n = strictcount(ASTDataFlow::Node otherSource | conf.hasFlow(otherSource, sink)) and n = strictcount(AstDataFlow::Node otherSource | conf.hasFlow(otherSource, sink)) and
( (
n = 1 and value = "" n = 1 and value = ""
or or

View File

@@ -4,7 +4,7 @@
*/ */
import cpp import cpp
import semmle.code.cpp.security.TaintTrackingImpl as ASTTaintTracking import semmle.code.cpp.security.TaintTrackingImpl as AstTaintTracking
import semmle.code.cpp.ir.dataflow.DefaultTaintTracking as IRDefaultTaintTracking import semmle.code.cpp.ir.dataflow.DefaultTaintTracking as IRDefaultTaintTracking
import IRDefaultTaintTracking::TaintedWithPath as TaintedWithPath import IRDefaultTaintTracking::TaintedWithPath as TaintedWithPath
import TaintedWithPath::Private import TaintedWithPath::Private
@@ -17,7 +17,7 @@ predicate isSinkArgument(Element sink) {
) )
} }
predicate astTaint(Expr source, Element sink) { ASTTaintTracking::tainted(source, sink) } predicate astTaint(Expr source, Element sink) { AstTaintTracking::tainted(source, sink) }
class SourceConfiguration extends TaintedWithPath::TaintTrackingConfiguration { class SourceConfiguration extends TaintedWithPath::TaintTrackingConfiguration {
override predicate isSink(Element e) { isSinkArgument(e) } override predicate isSink(Element e) { isSinkArgument(e) }

View File

@@ -5,7 +5,7 @@
*/ */
import cpp import cpp
import semmle.code.cpp.security.TaintTrackingImpl as ASTTaintTracking import semmle.code.cpp.security.TaintTrackingImpl as AstTaintTracking
import semmle.code.cpp.ir.dataflow.DefaultTaintTracking as IRDefaultTaintTracking import semmle.code.cpp.ir.dataflow.DefaultTaintTracking as IRDefaultTaintTracking
import IRDefaultTaintTracking::TaintedWithPath as TaintedWithPath import IRDefaultTaintTracking::TaintedWithPath as TaintedWithPath
import TestUtilities.InlineExpectationsTest import TestUtilities.InlineExpectationsTest
@@ -18,7 +18,7 @@ predicate argToSinkCall(Element sink) {
} }
predicate astTaint(Expr source, Element sink) { predicate astTaint(Expr source, Element sink) {
ASTTaintTracking::tainted(source, sink) and argToSinkCall(sink) AstTaintTracking::tainted(source, sink) and argToSinkCall(sink)
} }
class SourceConfiguration extends TaintedWithPath::TaintTrackingConfiguration { class SourceConfiguration extends TaintedWithPath::TaintTrackingConfiguration {

View File

@@ -1,11 +1,11 @@
import cpp import cpp
import semmle.code.cpp.security.Security import semmle.code.cpp.security.Security
import semmle.code.cpp.security.TaintTrackingImpl as ASTTaintTracking import semmle.code.cpp.security.TaintTrackingImpl as AstTaintTracking
import semmle.code.cpp.ir.dataflow.DefaultTaintTracking as IRDefaultTaintTracking import semmle.code.cpp.ir.dataflow.DefaultTaintTracking as IRDefaultTaintTracking
import TestUtilities.InlineExpectationsTest import TestUtilities.InlineExpectationsTest
predicate astTaint(Expr source, Element sink, string globalVar) { predicate astTaint(Expr source, Element sink, string globalVar) {
ASTTaintTracking::taintedIncludingGlobalVars(source, sink, globalVar) and globalVar != "" AstTaintTracking::taintedIncludingGlobalVars(source, sink, globalVar) and globalVar != ""
} }
predicate irTaint(Expr source, Element sink, string globalVar) { predicate irTaint(Expr source, Element sink, string globalVar) {

View File

@@ -1,5 +1,5 @@
--- ---
category: deprecated category: deprecated
--- ---
* Classes/predicates that had upper-case acronym XML in their name have been renamed to Xml to follow our style-guide. * Many classes/predicates/modules with upper-case acronyms in their name have been renamed to follow our style-guide.
The old name still exists as a deprecated alias. The old name still exists as a deprecated alias.

View File

@@ -94,14 +94,20 @@ class FormsElement extends XmlElement {
/** /**
* Gets attribute's `requireSSL` value. * Gets attribute's `requireSSL` value.
*/ */
string getRequireSSL() { string getRequireSsl() {
result = this.getAttribute("requireSSL").getValue().trim().toLowerCase() result = this.getAttribute("requireSSL").getValue().trim().toLowerCase()
} }
/** DEPRECATED: Alias for getRequireSsl */
deprecated string getRequireSSL() { result = this.getRequireSsl() }
/** /**
* Holds if `requireSSL` value is true. * Holds if `requireSSL` value is true.
*/ */
predicate isRequireSSL() { this.getRequireSSL() = "true" } predicate isRequireSsl() { this.getRequireSsl() = "true" }
/** DEPRECATED: Alias for isRequireSsl */
deprecated predicate isRequireSSL() { this.isRequireSsl() }
} }
/** A `<httpCookies>` tag in an ASP.NET configuration file. */ /** A `<httpCookies>` tag in an ASP.NET configuration file. */
@@ -123,17 +129,23 @@ class HttpCookiesElement extends XmlElement {
/** /**
* Gets attribute's `requireSSL` value. * Gets attribute's `requireSSL` value.
*/ */
string getRequireSSL() { string getRequireSsl() {
result = this.getAttribute("requireSSL").getValue().trim().toLowerCase() result = this.getAttribute("requireSSL").getValue().trim().toLowerCase()
} }
/** DEPRECATED: Alias for getRequireSsl */
deprecated string getRequireSSL() { result = this.getRequireSsl() }
/** /**
* Holds if there is any chance that `requireSSL` is set to `true` either globally or for Forms. * Holds if there is any chance that `requireSSL` is set to `true` either globally or for Forms.
*/ */
predicate isRequireSSL() { predicate isRequireSsl() {
this.getRequireSSL() = "true" this.getRequireSsl() = "true"
or or
not this.getRequireSSL() = "false" and // not set all, i.e. default not this.getRequireSsl() = "false" and // not set all, i.e. default
exists(FormsElement forms | forms.getFile() = this.getFile() | forms.isRequireSSL()) exists(FormsElement forms | forms.getFile() = this.getFile() | forms.isRequireSsl())
} }
/** DEPRECATED: Alias for isRequireSsl */
deprecated predicate isRequireSSL() { this.isRequireSsl() }
} }

View File

@@ -132,7 +132,10 @@ class XmlFile extends XmlParent, File {
XmlElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XmlDTD getADTD() { xmlDTDs(result, _, _, _, this) } XmlDtd getADtd() { xmlDTDs(result, _, _, _, this) }
/** DEPRECATED: Alias for getADtd */
deprecated XmlDtd getADTD() { result = this.getADtd() }
} }
/** DEPRECATED: Alias for XmlFile */ /** DEPRECATED: Alias for XmlFile */
@@ -149,7 +152,7 @@ deprecated class XMLFile = XmlFile;
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XmlDTD extends XmlLocatable, @xmldtd { class XmlDtd extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -174,8 +177,8 @@ class XmlDTD extends XmlLocatable, @xmldtd {
} }
} }
/** DEPRECATED: Alias for XmlDTD */ /** DEPRECATED: Alias for XmlDtd */
deprecated class XMLDTD = XmlDTD; deprecated class XMLDTD = XmlDtd;
/** /**
* An XML element in an XML file. * An XML element in an XML file.
@@ -282,15 +285,18 @@ class XmlNamespace extends XmlLocatable, @xmlnamespace {
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
/** Gets the URI of this namespace. */ /** Gets the URI of this namespace. */
string getURI() { xmlNs(this, _, result, _) } string getUri() { xmlNs(this, _, result, _) }
/** DEPRECATED: Alias for getUri */
deprecated string getURI() { result = this.getUri() }
/** Holds if this namespace has no prefix. */ /** Holds if this namespace has no prefix. */
predicate isDefault() { this.getPrefix() = "" } predicate isDefault() { this.getPrefix() = "" }
override string toString() { override string toString() {
this.isDefault() and result = this.getURI() this.isDefault() and result = this.getUri()
or or
not this.isDefault() and result = this.getPrefix() + ":" + this.getURI() not this.isDefault() and result = this.getPrefix() + ":" + this.getUri()
} }
} }

View File

@@ -119,10 +119,13 @@ class MicrosoftOwinIOwinRequestClass extends Class {
} }
/** Gets the `URI` property. */ /** Gets the `URI` property. */
Property getURIProperty() { Property getUriProperty() {
result = this.getAProperty() and result = this.getAProperty() and
result.hasName("URI") result.hasName("URI")
} }
/** DEPRECATED: Alias for getUriProperty */
deprecated Property getURIProperty() { result = this.getUriProperty() }
} }
/** A `Microsoft.Owin.*String` class. */ /** A `Microsoft.Owin.*String` class. */

View File

@@ -102,7 +102,9 @@ class UntrustedExternalApiDataNode extends ExternalApiDataNode {
/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ /** DEPRECATED: Alias for UntrustedExternalApiDataNode */
deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode;
/** An external API which is used with untrusted data. */
private newtype TExternalApi = private newtype TExternalApi =
/** An untrusted API method `m` where untrusted data is passed at `index`. */
TExternalApiParameter(Callable m, int index) { TExternalApiParameter(Callable m, int index) {
exists(UntrustedExternalApiDataNode n | exists(UntrustedExternalApiDataNode n |
m = n.getCallable().getUnboundDeclaration() and m = n.getCallable().getUnboundDeclaration() and

View File

@@ -146,7 +146,7 @@ class MicrosoftOwinRequestRemoteFlowSource extends RemoteFlowSource, DataFlow::E
p = owinRequest.getQueryStringProperty() or p = owinRequest.getQueryStringProperty() or
p = owinRequest.getRemoteIpAddressProperty() or p = owinRequest.getRemoteIpAddressProperty() or
p = owinRequest.getSchemeProperty() or p = owinRequest.getSchemeProperty() or
p = owinRequest.getURIProperty() p = owinRequest.getUriProperty()
) )
} }

View File

@@ -22,9 +22,9 @@ import semmle.code.csharp.frameworks.system.Web
from XmlElement element from XmlElement element
where where
element instanceof FormsElement and element instanceof FormsElement and
not element.(FormsElement).isRequireSSL() not element.(FormsElement).isRequireSsl()
or or
element instanceof HttpCookiesElement and element instanceof HttpCookiesElement and
not element.(HttpCookiesElement).isRequireSSL() and not element.(HttpCookiesElement).isRequireSsl() and
not any(SystemWebHttpCookie c).getSecureProperty().getAnAssignedValue().getValue() = "true" not any(SystemWebHttpCookie c).getSecureProperty().getAnAssignedValue().getValue() = "true"
select element, "The 'requireSSL' attribute is not set to 'true'." select element, "The 'requireSSL' attribute is not set to 'true'."

View File

@@ -66,10 +66,10 @@ where
// the `exists` below covers the `cs/web/requiressl-not-set` // the `exists` below covers the `cs/web/requiressl-not-set`
not exists(XmlElement element | not exists(XmlElement element |
element instanceof FormsElement and element instanceof FormsElement and
element.(FormsElement).isRequireSSL() element.(FormsElement).isRequireSsl()
or or
element instanceof HttpCookiesElement and element instanceof HttpCookiesElement and
element.(HttpCookiesElement).isRequireSSL() element.(HttpCookiesElement).isRequireSsl()
) )
) )
) )

View File

@@ -29,15 +29,15 @@ newtype TInstruction =
UnaliasedSsa::SSA::hasUnreachedInstruction(irFunc) UnaliasedSsa::SSA::hasUnreachedInstruction(irFunc)
} or } or
TAliasedSsaPhiInstruction( TAliasedSsaPhiInstruction(
TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation TRawInstruction blockStartInstr, AliasedSsa::SSA::MemoryLocation memoryLocation
) { ) {
AliasedSSA::SSA::hasPhiInstruction(blockStartInstr, memoryLocation) AliasedSsa::SSA::hasPhiInstruction(blockStartInstr, memoryLocation)
} or } or
TAliasedSsaChiInstruction(TRawInstruction primaryInstruction) { TAliasedSsaChiInstruction(TRawInstruction primaryInstruction) {
AliasedSSA::SSA::hasChiInstruction(primaryInstruction) AliasedSsa::SSA::hasChiInstruction(primaryInstruction)
} or } or
TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) { TAliasedSsaUnreachedInstruction(IRFunctionBase irFunc) {
AliasedSSA::SSA::hasUnreachedInstruction(irFunc) AliasedSsa::SSA::hasUnreachedInstruction(irFunc)
} }
/** /**
@@ -83,7 +83,7 @@ module AliasedSsaInstructions {
class TPhiInstruction = TAliasedSsaPhiInstruction or TUnaliasedSsaPhiInstruction; class TPhiInstruction = TAliasedSsaPhiInstruction or TUnaliasedSsaPhiInstruction;
TPhiInstruction phiInstruction( TPhiInstruction phiInstruction(
TRawInstruction blockStartInstr, AliasedSSA::SSA::MemoryLocation memoryLocation TRawInstruction blockStartInstr, AliasedSsa::SSA::MemoryLocation memoryLocation
) { ) {
result = TAliasedSsaPhiInstruction(blockStartInstr, memoryLocation) result = TAliasedSsaPhiInstruction(blockStartInstr, memoryLocation)
} }

View File

@@ -1,4 +1,7 @@
import experimental.ir.internal.IRCSharpLanguage as Language import experimental.ir.internal.IRCSharpLanguage as Language
import experimental.ir.implementation.raw.internal.IRConstruction as IRConstruction import experimental.ir.implementation.raw.internal.IRConstruction as IRConstruction
import experimental.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSsa import experimental.ir.implementation.unaliased_ssa.internal.SSAConstruction as UnaliasedSsa
import AliasedSSAStub as AliasedSSA import AliasedSSAStub as AliasedSsa
/** DEPRECATED: Alias for AliasedSsa */
deprecated module AliasedSSA = AliasedSsa;

View File

@@ -5,8 +5,8 @@ private import Imports::OperandTag
private import Imports::Overlap private import Imports::Overlap
private import Imports::TInstruction private import Imports::TInstruction
private import Imports::RawIR as RawIR private import Imports::RawIR as RawIR
private import SSAInstructions private import SsaInstructions
private import SSAOperands private import SsaOperands
private import NewIR private import NewIR
private class OldBlock = Reachability::ReachableBlock; private class OldBlock = Reachability::ReachableBlock;

View File

@@ -3,7 +3,14 @@ import experimental.ir.implementation.raw.internal.reachability.ReachableBlock a
import experimental.ir.implementation.raw.internal.reachability.Dominance as Dominance import experimental.ir.implementation.raw.internal.reachability.Dominance as Dominance
import experimental.ir.implementation.unaliased_ssa.IR as NewIR import experimental.ir.implementation.unaliased_ssa.IR as NewIR
import experimental.ir.implementation.raw.internal.IRConstruction as RawStage import experimental.ir.implementation.raw.internal.IRConstruction as RawStage
import experimental.ir.implementation.internal.TInstruction::UnaliasedSsaInstructions as SSAInstructions import experimental.ir.implementation.internal.TInstruction::UnaliasedSsaInstructions as SsaInstructions
/** DEPRECATED: Alias for SsaInstructions */
deprecated module SSAInstructions = SsaInstructions;
import experimental.ir.internal.IRCSharpLanguage as Language import experimental.ir.internal.IRCSharpLanguage as Language
import SimpleSSA as Alias import SimpleSSA as Alias
import experimental.ir.implementation.internal.TOperand::UnaliasedSsaOperands as SSAOperands import experimental.ir.implementation.internal.TOperand::UnaliasedSsaOperands as SsaOperands
/** DEPRECATED: Alias for SsaOperands */
deprecated module SSAOperands = SsaOperands;

View File

@@ -62,7 +62,7 @@ module Couchbase {
* A query used in an API function acting on a `Bucket` or `Cluster` struct of v1 of * A query used in an API function acting on a `Bucket` or `Cluster` struct of v1 of
* the official Couchbase Go library, gocb. * the official Couchbase Go library, gocb.
*/ */
private class CouchbaseV1Query extends NoSQL::Query::Range { private class CouchbaseV1Query extends NoSql::Query::Range {
CouchbaseV1Query() { CouchbaseV1Query() {
// func (b *Bucket) ExecuteAnalyticsQuery(q *AnalyticsQuery, params interface{}) (AnalyticsResults, error) // func (b *Bucket) ExecuteAnalyticsQuery(q *AnalyticsQuery, params interface{}) (AnalyticsResults, error)
// func (b *Bucket) ExecuteN1qlQuery(q *N1qlQuery, params interface{}) (QueryResults, error) // func (b *Bucket) ExecuteN1qlQuery(q *N1qlQuery, params interface{}) (QueryResults, error)
@@ -81,7 +81,7 @@ module Couchbase {
* A query used in an API function acting on a `Bucket` or `Cluster` struct of v1 of * A query used in an API function acting on a `Bucket` or `Cluster` struct of v1 of
* the official Couchbase Go library, gocb. * the official Couchbase Go library, gocb.
*/ */
private class CouchbaseV2Query extends NoSQL::Query::Range { private class CouchbaseV2Query extends NoSql::Query::Range {
CouchbaseV2Query() { CouchbaseV2Query() {
// func (c *Cluster) AnalyticsQuery(statement string, opts *AnalyticsOptions) (*AnalyticsResult, error) // func (c *Cluster) AnalyticsQuery(statement string, opts *AnalyticsOptions) (*AnalyticsResult, error)
// func (c *Cluster) Query(statement string, opts *QueryOptions) (*QueryResult, error) // func (c *Cluster) Query(statement string, opts *QueryOptions) (*QueryResult, error)

View File

@@ -43,8 +43,8 @@ module K8sIoApimachineryPkgRuntime {
} }
} }
private class DeepCopyJSON extends TaintTracking::FunctionModel { private class DeepCopyJson extends TaintTracking::FunctionModel {
DeepCopyJSON() { this.hasQualifiedName(packagePath(), ["DeepCopyJSON", "DeepCopyJSONValue"]) } DeepCopyJson() { this.hasQualifiedName(packagePath(), ["DeepCopyJSON", "DeepCopyJSONValue"]) }
override predicate hasTaintFlow(DataFlow::FunctionInput inp, DataFlow::FunctionOutput outp) { override predicate hasTaintFlow(DataFlow::FunctionInput inp, DataFlow::FunctionOutput outp) {
inp.isParameter(0) and outp.isResult() inp.isParameter(0) and outp.isResult()

View File

@@ -4,8 +4,8 @@
import go import go
/** Provides classes for working with NoSQL-related APIs. */ /** Provides classes for working with NoSql-related APIs. */
module NoSQL { module NoSql {
/** /**
* A data-flow node whose value is interpreted as (part of) a NoSQL query. * A data-flow node whose value is interpreted as (part of) a NoSQL query.
* *
@@ -18,7 +18,7 @@ module NoSQL {
Query() { this = self } Query() { this = self }
} }
/** Provides classes for working with NoSQL queries. */ /** Provides classes for working with NoSql queries. */
module Query { module Query {
/** /**
* A data-flow node whose value is interpreted as (part of) a NoSQL query. * A data-flow node whose value is interpreted as (part of) a NoSQL query.
@@ -119,3 +119,6 @@ module NoSQL {
) )
} }
} }
/** DEPRECATED: Alias for NoSql */
deprecated module NoSQL = NoSql;

View File

@@ -69,9 +69,9 @@ import semmle.go.frameworks.stdlib.TextTemplate
/** A `String()` method. */ /** A `String()` method. */
class StringMethod extends TaintTracking::FunctionModel, Method { class StringMethod extends TaintTracking::FunctionModel, Method {
StringMethod() { StringMethod() {
getName() = "String" and this.getName() = "String" and
getNumParameter() = 0 and this.getNumParameter() = 0 and
getResultType(0) = Builtin::string_().getType() this.getResultType(0) = Builtin::string_().getType()
} }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) { override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
@@ -132,7 +132,8 @@ module URL {
/** The `PathEscape` or `QueryEscape` function. */ /** The `PathEscape` or `QueryEscape` function. */
class Escaper extends TaintTracking::FunctionModel { class Escaper extends TaintTracking::FunctionModel {
Escaper() { Escaper() {
hasQualifiedName("net/url", "PathEscape") or hasQualifiedName("net/url", "QueryEscape") this.hasQualifiedName("net/url", "PathEscape") or
this.hasQualifiedName("net/url", "QueryEscape")
} }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) { override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
@@ -143,7 +144,8 @@ module URL {
/** The `PathUnescape` or `QueryUnescape` function. */ /** The `PathUnescape` or `QueryUnescape` function. */
class Unescaper extends TaintTracking::FunctionModel { class Unescaper extends TaintTracking::FunctionModel {
Unescaper() { Unescaper() {
hasQualifiedName("net/url", "PathUnescape") or hasQualifiedName("net/url", "QueryUnescape") this.hasQualifiedName("net/url", "PathUnescape") or
this.hasQualifiedName("net/url", "QueryUnescape")
} }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) { override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
@@ -154,10 +156,10 @@ module URL {
/** The `Parse`, `ParseQuery` or `ParseRequestURI` function, or the `URL.Parse` method. */ /** The `Parse`, `ParseQuery` or `ParseRequestURI` function, or the `URL.Parse` method. */
class Parser extends TaintTracking::FunctionModel { class Parser extends TaintTracking::FunctionModel {
Parser() { Parser() {
hasQualifiedName("net/url", "Parse") or this.hasQualifiedName("net/url", "Parse") or
this.(Method).hasQualifiedName("net/url", "URL", "Parse") or this.(Method).hasQualifiedName("net/url", "URL", "Parse") or
hasQualifiedName("net/url", "ParseQuery") or this.hasQualifiedName("net/url", "ParseQuery") or
hasQualifiedName("net/url", "ParseRequestURI") this.hasQualifiedName("net/url", "ParseRequestURI")
} }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) { override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
@@ -192,7 +194,7 @@ module URL {
/** A method that returns a part of a URL. */ /** A method that returns a part of a URL. */
class UrlGetter extends TaintTracking::FunctionModel, Method { class UrlGetter extends TaintTracking::FunctionModel, Method {
UrlGetter() { UrlGetter() {
exists(string m | hasQualifiedName("net/url", "URL", m) | exists(string m | this.hasQualifiedName("net/url", "URL", m) |
m = ["EscapedPath", "Hostname", "Port", "Query", "RequestURI"] m = ["EscapedPath", "Hostname", "Port", "Query", "RequestURI"]
) )
} }
@@ -204,7 +206,7 @@ module URL {
/** The method `URL.MarshalBinary`. */ /** The method `URL.MarshalBinary`. */
class UrlMarshalBinary extends TaintTracking::FunctionModel, Method { class UrlMarshalBinary extends TaintTracking::FunctionModel, Method {
UrlMarshalBinary() { hasQualifiedName("net/url", "URL", "MarshalBinary") } UrlMarshalBinary() { this.hasQualifiedName("net/url", "URL", "MarshalBinary") }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) { override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
inp.isReceiver() and outp.isResult(0) inp.isReceiver() and outp.isResult(0)
@@ -213,7 +215,7 @@ module URL {
/** The method `URL.ResolveReference`. */ /** The method `URL.ResolveReference`. */
class UrlResolveReference extends TaintTracking::FunctionModel, Method { class UrlResolveReference extends TaintTracking::FunctionModel, Method {
UrlResolveReference() { hasQualifiedName("net/url", "URL", "ResolveReference") } UrlResolveReference() { this.hasQualifiedName("net/url", "URL", "ResolveReference") }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) { override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
(inp.isReceiver() or inp.isParameter(0)) and (inp.isReceiver() or inp.isParameter(0)) and
@@ -224,8 +226,8 @@ module URL {
/** The function `User` or `UserPassword`. */ /** The function `User` or `UserPassword`. */
class UserinfoConstructor extends TaintTracking::FunctionModel { class UserinfoConstructor extends TaintTracking::FunctionModel {
UserinfoConstructor() { UserinfoConstructor() {
hasQualifiedName("net/url", "User") or this.hasQualifiedName("net/url", "User") or
hasQualifiedName("net/url", "UserPassword") this.hasQualifiedName("net/url", "UserPassword")
} }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) { override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
@@ -236,7 +238,7 @@ module URL {
/** A method that returns a part of a Userinfo struct. */ /** A method that returns a part of a Userinfo struct. */
class UserinfoGetter extends TaintTracking::FunctionModel, Method { class UserinfoGetter extends TaintTracking::FunctionModel, Method {
UserinfoGetter() { UserinfoGetter() {
exists(string m | hasQualifiedName("net/url", "Userinfo", m) | exists(string m | this.hasQualifiedName("net/url", "Userinfo", m) |
m = "Password" or m = "Password" or
m = "Username" m = "Username"
) )
@@ -250,7 +252,7 @@ module URL {
/** A method that returns all or part of a Values map. */ /** A method that returns all or part of a Values map. */
class ValuesGetter extends TaintTracking::FunctionModel, Method { class ValuesGetter extends TaintTracking::FunctionModel, Method {
ValuesGetter() { ValuesGetter() {
exists(string m | hasQualifiedName("net/url", "Values", m) | exists(string m | this.hasQualifiedName("net/url", "Values", m) |
m = "Encode" or m = "Encode" or
m = "Get" m = "Get"
) )

View File

@@ -288,8 +288,8 @@ module WebSocketReader {
/** /**
* The `ServerWebSocket.MessageReceiveJSON` method of the `github.com/revel/revel` package. * The `ServerWebSocket.MessageReceiveJSON` method of the `github.com/revel/revel` package.
*/ */
private class RevelServerWebSocketMessageReceiveJSON extends Range, Method { private class RevelServerWebSocketMessageReceiveJson extends Range, Method {
RevelServerWebSocketMessageReceiveJSON() { RevelServerWebSocketMessageReceiveJson() {
// func MessageReceiveJSON(v interface{}) error // func MessageReceiveJSON(v interface{}) error
this.hasQualifiedName(Revel::packagePath(), "ServerWebSocket", "MessageReceiveJSON") this.hasQualifiedName(Revel::packagePath(), "ServerWebSocket", "MessageReceiveJSON")
} }

View File

@@ -14,15 +14,18 @@ private import Logrus
/** /**
* A `Function` that is considered a "safe" external API from a security perspective. * A `Function` that is considered a "safe" external API from a security perspective.
*/ */
abstract class SafeExternalAPIFunction extends Function { } abstract class SafeExternalApiFunction extends Function { }
/** DEPRECATED: Alias for SafeExternalApiFunction */
deprecated class SafeExternalAPIFunction = SafeExternalApiFunction;
private predicate isDefaultSafePackage(Package package) { private predicate isDefaultSafePackage(Package package) {
package.getPath() in ["time", "unicode/utf8", package("gopkg.in/go-playground/validator", "")] package.getPath() in ["time", "unicode/utf8", package("gopkg.in/go-playground/validator", "")]
} }
/** The default set of "safe" external APIs. */ /** The default set of "safe" external APIs. */
private class DefaultSafeExternalAPIFunction extends SafeExternalAPIFunction { private class DefaultSafeExternalApiFunction extends SafeExternalApiFunction {
DefaultSafeExternalAPIFunction() { DefaultSafeExternalApiFunction() {
this instanceof BuiltinFunction or this instanceof BuiltinFunction or
isDefaultSafePackage(this.getPackage()) or isDefaultSafePackage(this.getPackage()) or
this.hasQualifiedName(package("gopkg.in/square/go-jose", "jwt"), "ParseSigned") or this.hasQualifiedName(package("gopkg.in/square/go-jose", "jwt"), "ParseSigned") or
@@ -52,11 +55,11 @@ private predicate isProbableLocalFunctionPointer(DataFlow::CallNode callNode) {
} }
/** A node representing data being passed to an external API. */ /** A node representing data being passed to an external API. */
class ExternalAPIDataNode extends DataFlow::Node { class ExternalApiDataNode extends DataFlow::Node {
DataFlow::CallNode call; DataFlow::CallNode call;
int i; int i;
ExternalAPIDataNode() { ExternalApiDataNode() {
( (
// Argument to call to a function // Argument to call to a function
this = call.getArgument(i) this = call.getArgument(i)
@@ -74,7 +77,7 @@ class ExternalAPIDataNode extends DataFlow::Node {
// Not already modeled as a taint step // Not already modeled as a taint step
not exists(DataFlow::Node next | TaintTracking::localTaintStep(this, next)) and not exists(DataFlow::Node next | TaintTracking::localTaintStep(this, next)) and
// Not a call to a known safe external API // Not a call to a known safe external API
not call.getTarget() instanceof SafeExternalAPIFunction not call.getTarget() instanceof SafeExternalApiFunction
} }
/** Gets the called API `Function`. */ /** Gets the called API `Function`. */
@@ -102,6 +105,9 @@ class ExternalAPIDataNode extends DataFlow::Node {
} }
} }
/** DEPRECATED: Alias for ExternalApiDataNode */
deprecated class ExternalAPIDataNode = ExternalApiDataNode;
/** Gets the name of a method in package `p` which has a function model. */ /** Gets the name of a method in package `p` which has a function model. */
TaintTracking::FunctionModel getAMethodModelInPackage(Package p) { TaintTracking::FunctionModel getAMethodModelInPackage(Package p) {
p = result.getPackage() and p = result.getPackage() and
@@ -140,8 +146,8 @@ predicate isACommonSink(DataFlow::Node n) {
} }
/** A node representing data being passed to an unknown external API. */ /** A node representing data being passed to an unknown external API. */
class UnknownExternalAPIDataNode extends ExternalAPIDataNode { class UnknownExternalApiDataNode extends ExternalApiDataNode {
UnknownExternalAPIDataNode() { UnknownExternalApiDataNode() {
// Not a sink for a commonly-used query // Not a sink for a commonly-used query
not isACommonSink(this) and not isACommonSink(this) and
// Not in a package that has some functions modeled // Not in a package that has some functions modeled
@@ -149,47 +155,61 @@ class UnknownExternalAPIDataNode extends ExternalAPIDataNode {
} }
} }
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */ /** DEPRECATED: Alias for UnknownExternalApiDataNode */
class UntrustedDataToExternalAPIConfig extends TaintTracking::Configuration { deprecated class UnknownExternalAPIDataNode = UnknownExternalApiDataNode;
UntrustedDataToExternalAPIConfig() { this = "UntrustedDataToExternalAPIConfig" }
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration {
UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfig" }
override predicate isSource(DataFlow::Node source) { source instanceof UntrustedFlowSource } override predicate isSource(DataFlow::Node source) { source instanceof UntrustedFlowSource }
override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalAPIDataNode } override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }
} }
/** A configuration for tracking flow from `RemoteFlowSource`s to `UnknownExternalAPIDataNode`s. */ /** DEPRECATED: Alias for UntrustedDataToExternalApiConfig */
class UntrustedDataToUnknownExternalAPIConfig extends TaintTracking::Configuration { deprecated class UntrustedDataToExternalAPIConfig = UntrustedDataToExternalApiConfig;
UntrustedDataToUnknownExternalAPIConfig() { this = "UntrustedDataToUnknownExternalAPIConfig" }
/** A configuration for tracking flow from `RemoteFlowSource`s to `UnknownExternalApiDataNode`s. */
class UntrustedDataToUnknownExternalApiConfig extends TaintTracking::Configuration {
UntrustedDataToUnknownExternalApiConfig() { this = "UntrustedDataToUnknownExternalAPIConfig" }
override predicate isSource(DataFlow::Node source) { source instanceof UntrustedFlowSource } override predicate isSource(DataFlow::Node source) { source instanceof UntrustedFlowSource }
override predicate isSink(DataFlow::Node sink) { sink instanceof UnknownExternalAPIDataNode } override predicate isSink(DataFlow::Node sink) { sink instanceof UnknownExternalApiDataNode }
} }
/** DEPRECATED: Alias for UntrustedDataToUnknownExternalApiConfig */
deprecated class UntrustedDataToUnknownExternalAPIConfig = UntrustedDataToUnknownExternalApiConfig;
/** A node representing untrusted data being passed to an external API. */ /** A node representing untrusted data being passed to an external API. */
class UntrustedExternalAPIDataNode extends ExternalAPIDataNode { class UntrustedExternalApiDataNode extends ExternalApiDataNode {
UntrustedExternalAPIDataNode() { any(UntrustedDataToExternalAPIConfig c).hasFlow(_, this) } UntrustedExternalApiDataNode() { any(UntrustedDataToExternalApiConfig c).hasFlow(_, this) }
/** Gets a source of untrusted data which is passed to this external API data node. */ /** Gets a source of untrusted data which is passed to this external API data node. */
DataFlow::Node getAnUntrustedSource() { DataFlow::Node getAnUntrustedSource() {
any(UntrustedDataToExternalAPIConfig c).hasFlow(result, this) any(UntrustedDataToExternalApiConfig c).hasFlow(result, this)
} }
} }
private newtype TExternalAPI = /** DEPRECATED: Alias for UntrustedExternalApiDataNode */
TExternalAPIParameter(Function m, int index) { deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode;
exists(UntrustedExternalAPIDataNode n |
/** An external API which is used with untrusted data. */
private newtype TExternalApi =
/** An untrusted API method `m` where untrusted data is passed at `index`. */
TExternalApiParameter(Function m, int index) {
exists(UntrustedExternalApiDataNode n |
m = n.getFunction() and m = n.getFunction() and
index = n.getIndex() index = n.getIndex()
) )
} }
/** An external API which is used with untrusted data. */ /** An external API which is used with untrusted data. */
class ExternalAPIUsedWithUntrustedData extends TExternalAPI { class ExternalApiUsedWithUntrustedData extends TExternalApi {
/** Gets a possibly untrusted use of this external API. */ /** Gets a possibly untrusted use of this external API. */
UntrustedExternalAPIDataNode getUntrustedDataNode() { UntrustedExternalApiDataNode getUntrustedDataNode() {
this = TExternalAPIParameter(result.getFunction(), result.getIndex()) this = TExternalApiParameter(result.getFunction(), result.getIndex())
} }
/** Gets the number of untrusted sources used with this external API. */ /** Gets the number of untrusted sources used with this external API. */
@@ -202,10 +222,13 @@ class ExternalAPIUsedWithUntrustedData extends TExternalAPI {
exists(Function f, int index, string indexString | exists(Function f, int index, string indexString |
if index = -1 then indexString = "receiver" else indexString = "param " + index if index = -1 then indexString = "receiver" else indexString = "param " + index
| |
this = TExternalAPIParameter(f, index) and this = TExternalApiParameter(f, index) and
if exists(f.getQualifiedName()) if exists(f.getQualifiedName())
then result = f.getQualifiedName() + " [" + indexString + "]" then result = f.getQualifiedName() + " [" + indexString + "]"
else result = f.getName() + " [" + indexString + "]" else result = f.getName() + " [" + indexString + "]"
) )
} }
} }
/** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */
deprecated class ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData;

View File

@@ -24,7 +24,7 @@ module SqlInjection {
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink } override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) { override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
NoSQL::isAdditionalMongoTaintStep(pred, succ) NoSql::isAdditionalMongoTaintStep(pred, succ)
} }
override predicate isSanitizer(DataFlow::Node node) { override predicate isSanitizer(DataFlow::Node node) {

View File

@@ -42,8 +42,8 @@ module SqlInjection {
SqlQueryAsSink() { this instanceof SQL::QueryString } SqlQueryAsSink() { this instanceof SQL::QueryString }
} }
/** A NoSQL query, considered as a taint sink for SQL injection. */ /** A NoSql query, considered as a taint sink for SQL injection. */
class NoSqlQueryAsSink extends Sink { class NoSqlQueryAsSink extends Sink {
NoSqlQueryAsSink() { this instanceof NoSQL::Query } NoSqlQueryAsSink() { this instanceof NoSql::Query }
} }
} }

View File

@@ -11,7 +11,7 @@
import go import go
import semmle.go.security.ExternalAPIs import semmle.go.security.ExternalAPIs
from ExternalAPIUsedWithUntrustedData externalAPI from ExternalApiUsedWithUntrustedData externalApi
select externalAPI, count(externalAPI.getUntrustedDataNode()) as numberOfUses, select externalApi, count(externalApi.getUntrustedDataNode()) as numberOfUses,
externalAPI.getNumberOfUntrustedSources() as numberOfUntrustedSources order by externalApi.getNumberOfUntrustedSources() as numberOfUntrustedSources order by
numberOfUntrustedSources desc numberOfUntrustedSources desc

View File

@@ -13,8 +13,8 @@ import go
import semmle.go.security.ExternalAPIs import semmle.go.security.ExternalAPIs
import DataFlow::PathGraph import DataFlow::PathGraph
from UntrustedDataToExternalAPIConfig config, DataFlow::PathNode source, DataFlow::PathNode sink from UntrustedDataToExternalApiConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink) where config.hasFlowPath(source, sink)
select sink, source, sink, select sink, source, sink,
"Call to " + sink.getNode().(ExternalAPIDataNode).getFunctionDescription() + "Call to " + sink.getNode().(ExternalApiDataNode).getFunctionDescription() +
" with untrusted data from $@.", source, source.toString() " with untrusted data from $@.", source, source.toString()

View File

@@ -14,8 +14,8 @@ import semmle.go.security.ExternalAPIs
import DataFlow::PathGraph import DataFlow::PathGraph
from from
UntrustedDataToUnknownExternalAPIConfig config, DataFlow::PathNode source, DataFlow::PathNode sink UntrustedDataToUnknownExternalApiConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink) where config.hasFlowPath(source, sink)
select sink, source, sink, select sink, source, sink,
"Call to " + sink.getNode().(UnknownExternalAPIDataNode).getFunctionDescription() + "Call to " + sink.getNode().(UnknownExternalApiDataNode).getFunctionDescription() +
" with untrusted data from $@.", source, source.toString() " with untrusted data from $@.", source, source.toString()

View File

@@ -18,8 +18,8 @@ import DataFlow::PathGraph
* A method that creates a new URL that will send the user * A method that creates a new URL that will send the user
* to the OAuth 2.0 authorization dialog of the provider. * to the OAuth 2.0 authorization dialog of the provider.
*/ */
class AuthCodeURL extends Method { class AuthCodeUrl extends Method {
AuthCodeURL() { AuthCodeUrl() {
this.hasQualifiedName(package("golang.org/x/oauth2", ""), "Config", "AuthCodeURL") this.hasQualifiedName(package("golang.org/x/oauth2", ""), "Config", "AuthCodeURL")
} }
} }
@@ -32,7 +32,7 @@ class ConstantStateFlowConf extends DataFlow::Configuration {
ConstantStateFlowConf() { this = "ConstantStateFlowConf" } ConstantStateFlowConf() { this = "ConstantStateFlowConf" }
predicate isSink(DataFlow::Node sink, DataFlow::CallNode call) { predicate isSink(DataFlow::Node sink, DataFlow::CallNode call) {
exists(AuthCodeURL m | call = m.getACall() | sink = call.getArgument(0)) exists(AuthCodeUrl m | call = m.getACall() | sink = call.getArgument(0))
} }
override predicate isSource(DataFlow::Node source) { override predicate isSource(DataFlow::Node source) {
@@ -110,7 +110,7 @@ class PrivateUrlFlowsToAuthCodeUrlCall extends DataFlow::Configuration {
} }
predicate isSink(DataFlow::Node sink, DataFlow::CallNode call) { predicate isSink(DataFlow::Node sink, DataFlow::CallNode call) {
exists(AuthCodeURL m | call = m.getACall() | sink = call.getReceiver()) exists(AuthCodeUrl m | call = m.getACall() | sink = call.getReceiver())
} }
override predicate isSink(DataFlow::Node sink) { this.isSink(sink, _) } override predicate isSink(DataFlow::Node sink) { this.isSink(sink, _) }
@@ -130,7 +130,7 @@ predicate privateUrlFlowsToAuthCodeUrlCall(DataFlow::CallNode call) {
) )
} }
/** A flow from `golang.org/x/oauth2.Config.AuthCodeURL`'s result to a logging function. */ /** A flow from `golang.org/x/oauth2.Config.AuthCodeUrl`'s result to a logging function. */
class FlowToPrint extends DataFlow::Configuration { class FlowToPrint extends DataFlow::Configuration {
FlowToPrint() { this = "FlowToPrint" } FlowToPrint() { this = "FlowToPrint" }
@@ -139,17 +139,17 @@ class FlowToPrint extends DataFlow::Configuration {
} }
override predicate isSource(DataFlow::Node source) { override predicate isSource(DataFlow::Node source) {
source = any(AuthCodeURL m).getACall().getResult() source = any(AuthCodeUrl m).getACall().getResult()
} }
override predicate isSink(DataFlow::Node sink) { this.isSink(sink, _) } override predicate isSink(DataFlow::Node sink) { this.isSink(sink, _) }
} }
/** Holds if the provided `CallNode`'s result flows to an argument of a printer call. */ /** Holds if the provided `CallNode`'s result flows to an argument of a printer call. */
predicate resultFlowsToPrinter(DataFlow::CallNode authCodeURLCall) { predicate resultFlowsToPrinter(DataFlow::CallNode authCodeUrlCall) {
exists(FlowToPrint cfg, DataFlow::PathNode source, DataFlow::PathNode sink | exists(FlowToPrint cfg, DataFlow::PathNode source, DataFlow::PathNode sink |
cfg.hasFlowPath(source, sink) and cfg.hasFlowPath(source, sink) and
authCodeURLCall.getResult() = source.getNode() authCodeUrlCall.getResult() = source.getNode()
) )
} }
@@ -188,9 +188,9 @@ predicate containsCallToStdinScanner(FuncDef funcDef) { getAScannerCall().getRoo
* and a call to a scanner (`fmt.Scan` and similar), * and a call to a scanner (`fmt.Scan` and similar),
* all of which are typically done within a terminal session. * all of which are typically done within a terminal session.
*/ */
predicate seemsLikeDoneWithinATerminal(DataFlow::CallNode authCodeURLCall) { predicate seemsLikeDoneWithinATerminal(DataFlow::CallNode authCodeUrlCall) {
resultFlowsToPrinter(authCodeURLCall) and resultFlowsToPrinter(authCodeUrlCall) and
containsCallToStdinScanner(authCodeURLCall.getRoot()) containsCallToStdinScanner(authCodeUrlCall.getRoot())
} }
from from

View File

@@ -1,13 +1,13 @@
import go import go
import TestUtilities.InlineExpectationsTest import TestUtilities.InlineExpectationsTest
class NoSQLQueryTest extends InlineExpectationsTest { class NoSqlQueryTest extends InlineExpectationsTest {
NoSQLQueryTest() { this = "NoSQLQueryTest" } NoSqlQueryTest() { this = "NoSQLQueryTest" }
override string getARelevantTag() { result = "nosqlquery" } override string getARelevantTag() { result = "nosqlquery" }
override predicate hasActualResult(Location location, string element, string tag, string value) { override predicate hasActualResult(Location location, string element, string tag, string value) {
exists(NoSQL::Query q | exists(NoSql::Query q |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
element = q.toString() and element = q.toString() and

View File

@@ -1,8 +1,8 @@
import go import go
import TestUtilities.InlineExpectationsTest import TestUtilities.InlineExpectationsTest
class SQLTest extends InlineExpectationsTest { class SqlTest extends InlineExpectationsTest {
SQLTest() { this = "SQLTest" } SqlTest() { this = "SQLTest" }
override string getARelevantTag() { result = "query" } override string getARelevantTag() { result = "query" }

View File

@@ -1,5 +1,5 @@
--- ---
category: deprecated category: deprecated
--- ---
* Classes/predicates that had upper-case acronym XML in their name have been renamed to Xml to follow our style-guide. * Many classes/predicates/modules with upper-case acronyms in their name have been renamed to follow our style-guide.
The old name still exists as a deprecated alias. The old name still exists as a deprecated alias.

View File

@@ -19,33 +19,45 @@ class EnterpriseBean extends RefType {
} }
/** A local EJB home interface. */ /** A local EJB home interface. */
class LocalEJBHomeInterface extends Interface { class LocalEjbHomeInterface extends Interface {
LocalEJBHomeInterface() { LocalEjbHomeInterface() {
exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBLocalHome") | this.hasSupertype+(i)) exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBLocalHome") | this.hasSupertype+(i))
} }
} }
/** DEPRECATED: Alias for LocalEjbHomeInterface */
deprecated class LocalEJBHomeInterface = LocalEjbHomeInterface;
/** A remote EJB home interface. */ /** A remote EJB home interface. */
class RemoteEJBHomeInterface extends Interface { class RemoteEjbHomeInterface extends Interface {
RemoteEJBHomeInterface() { RemoteEjbHomeInterface() {
exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBHome") | this.hasSupertype+(i)) exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBHome") | this.hasSupertype+(i))
} }
} }
/** DEPRECATED: Alias for RemoteEjbHomeInterface */
deprecated class RemoteEJBHomeInterface = RemoteEjbHomeInterface;
/** A local EJB interface. */ /** A local EJB interface. */
class LocalEJBInterface extends Interface { class LocalEjbInterface extends Interface {
LocalEJBInterface() { LocalEjbInterface() {
exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBLocalObject") | this.hasSupertype+(i)) exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBLocalObject") | this.hasSupertype+(i))
} }
} }
/** DEPRECATED: Alias for LocalEjbInterface */
deprecated class LocalEJBInterface = LocalEjbInterface;
/** A remote EJB interface. */ /** A remote EJB interface. */
class RemoteEJBInterface extends Interface { class RemoteEjbInterface extends Interface {
RemoteEJBInterface() { RemoteEjbInterface() {
exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBObject") | this.hasSupertype+(i)) exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBObject") | this.hasSupertype+(i))
} }
} }
/** DEPRECATED: Alias for RemoteEjbInterface */
deprecated class RemoteEJBInterface = RemoteEjbInterface;
/** A message bean. */ /** A message bean. */
class MessageBean extends Class { class MessageBean extends Class {
MessageBean() { MessageBean() {

View File

@@ -314,21 +314,27 @@ class FacesComponentReflectivelyConstructedClass extends ReflectivelyConstructed
/** /**
* Entry point for EJB home interfaces. * Entry point for EJB home interfaces.
*/ */
class EJBHome extends Interface, EntryPoint { class EjbHome extends Interface, EntryPoint {
EJBHome() { this.getAnAncestor().hasQualifiedName("javax.ejb", "EJBHome") } EjbHome() { this.getAnAncestor().hasQualifiedName("javax.ejb", "EJBHome") }
override Callable getALiveCallable() { result = this.getACallable() } override Callable getALiveCallable() { result = this.getACallable() }
} }
/** DEPRECATED: Alias for EjbHome */
deprecated class EJBHome = EjbHome;
/** /**
* Entry point for EJB object interfaces. * Entry point for EJB object interfaces.
*/ */
class EJBObject extends Interface, EntryPoint { class EjbObject extends Interface, EntryPoint {
EJBObject() { this.getAnAncestor().hasQualifiedName("javax.ejb", "EJBObject") } EjbObject() { this.getAnAncestor().hasQualifiedName("javax.ejb", "EJBObject") }
override Callable getALiveCallable() { result = this.getACallable() } override Callable getALiveCallable() { result = this.getACallable() }
} }
/** DEPRECATED: Alias for EjbObject */
deprecated class EJBObject = EjbObject;
class GsonDeserializationEntryPoint extends ReflectivelyConstructedClass { class GsonDeserializationEntryPoint extends ReflectivelyConstructedClass {
GsonDeserializationEntryPoint() { GsonDeserializationEntryPoint() {
// Assume any class with a gson annotated field can be deserialized. // Assume any class with a gson annotated field can be deserialized.

View File

@@ -10,19 +10,22 @@ import semmle.code.java.frameworks.camel.CamelJavaAnnotations
/** /**
* A string describing a URI specified in an Apache Camel "to" declaration. * A string describing a URI specified in an Apache Camel "to" declaration.
*/ */
class CamelToURI extends string { class CamelToUri extends string {
CamelToURI() { CamelToUri() {
exists(SpringCamelXmlToElement toXmlElement | this = toXmlElement.getURI()) or exists(SpringCamelXmlToElement toXmlElement | this = toXmlElement.getUri()) or
exists(CamelJavaDSLToDecl toJavaDSL | this = toJavaDSL.getURI()) exists(CamelJavaDSLToDecl toJavaDSL | this = toJavaDSL.getUri())
} }
} }
/** DEPRECATED: Alias for CamelToUri */
deprecated class CamelToURI = CamelToUri;
/** /**
* A string describing a URI specified in an Apache Camel "to" declaration that maps to a * A string describing a URI specified in an Apache Camel "to" declaration that maps to a
* SpringBean. * SpringBean.
*/ */
class CamelToBeanURI extends CamelToURI { class CamelToBeanUri extends CamelToUri {
CamelToBeanURI() { CamelToBeanUri() {
// A `<to>` element references a bean if the URI starts with "bean:", or there is no scheme. // A `<to>` element references a bean if the URI starts with "bean:", or there is no scheme.
matches("bean:%") or matches("bean:%") or
not exists(indexOf(":")) not exists(indexOf(":"))
@@ -51,6 +54,9 @@ class CamelToBeanURI extends CamelToURI {
SpringBean getRefBean() { result.getBeanIdentifier() = this.getBeanIdentifier() } SpringBean getRefBean() { result.getBeanIdentifier() = this.getBeanIdentifier() }
} }
/** DEPRECATED: Alias for CamelToBeanUri */
deprecated class CamelToBeanURI = CamelToBeanUri;
/** /**
* A Class whose methods may be called in response to an Apache Camel message. * A Class whose methods may be called in response to an Apache Camel message.
*/ */
@@ -64,7 +70,7 @@ class CamelTargetClass extends Class {
this = camelXmlBeanRef.getBeanType() this = camelXmlBeanRef.getBeanType()
) )
or or
exists(CamelToBeanURI toBeanURI | this = toBeanURI.getRefBean().getClass()) exists(CamelToBeanUri toBeanUri | this = toBeanUri.getRefBean().getClass())
or or
exists(SpringCamelXmlMethodElement xmlMethod | exists(SpringCamelXmlMethodElement xmlMethod |
this = xmlMethod.getRefBean().getClass() or this = xmlMethod.getRefBean().getClass() or

View File

@@ -134,14 +134,17 @@ deprecated class HttpServletRequestGetRequestURLMethod = HttpServletRequestGetRe
/** /**
* The method `getRequestURI()` declared in `javax.servlet.http.HttpServletRequest`. * The method `getRequestURI()` declared in `javax.servlet.http.HttpServletRequest`.
*/ */
class HttpServletRequestGetRequestURIMethod extends Method { class HttpServletRequestGetRequestUriMethod extends Method {
HttpServletRequestGetRequestURIMethod() { HttpServletRequestGetRequestUriMethod() {
this.getDeclaringType() instanceof HttpServletRequest and this.getDeclaringType() instanceof HttpServletRequest and
this.hasName("getRequestURI") and this.hasName("getRequestURI") and
this.getNumberOfParameters() = 0 this.getNumberOfParameters() = 0
} }
} }
/** DEPRECATED: Alias for HttpServletRequestGetRequestUriMethod */
deprecated class HttpServletRequestGetRequestURIMethod = HttpServletRequestGetRequestUriMethod;
/** /**
* The method `getRemoteUser()` declared in `javax.servlet.http.HttpServletRequest`. * The method `getRemoteUser()` declared in `javax.servlet.http.HttpServletRequest`.
*/ */

View File

@@ -41,7 +41,10 @@ class CamelJavaDSLToDecl extends ProcessorDefinitionElement {
/** /**
* Gets the URI specified by this `to` declaration. * Gets the URI specified by this `to` declaration.
*/ */
string getURI() { result = getArgument(0).(CompileTimeConstantExpr).getStringValue() } string getUri() { result = getArgument(0).(CompileTimeConstantExpr).getStringValue() }
/** DEPRECATED: Alias for getUri */
deprecated string getURI() { result = getUri() }
} }
/** /**

View File

@@ -92,19 +92,25 @@ private predicate jsniComment(Javadoc jsni, Method m) {
* A JavaScript Native Interface (JSNI) comment that contains JavaScript code * A JavaScript Native Interface (JSNI) comment that contains JavaScript code
* implementing a native method. * implementing a native method.
*/ */
class JSNIComment extends Javadoc { class JsniComment extends Javadoc {
JSNIComment() { jsniComment(this, _) } JsniComment() { jsniComment(this, _) }
/** Gets the method implemented by this comment. */ /** Gets the method implemented by this comment. */
Method getImplementedMethod() { jsniComment(this, result) } Method getImplementedMethod() { jsniComment(this, result) }
} }
/** DEPRECATED: Alias for JsniComment */
deprecated class JSNIComment = JsniComment;
/** /**
* A JavaScript Native Interface (JSNI) method. * A JavaScript Native Interface (JSNI) method.
*/ */
class JSNIMethod extends Method { class JsniMethod extends Method {
JSNIMethod() { jsniComment(_, this) } JsniMethod() { jsniComment(_, this) }
/** Gets the comment containing the JavaScript code for this method. */ /** Gets the comment containing the JavaScript code for this method. */
JSNIComment getImplementation() { jsniComment(result, this) } JsniComment getImplementation() { jsniComment(result, this) }
} }
/** DEPRECATED: Alias for JsniMethod */
deprecated class JSNIMethod = JsniMethod;

View File

@@ -17,7 +17,7 @@ class GwtUiBinderTemplateElement extends XmlElement {
GwtUiBinderTemplateElement() { GwtUiBinderTemplateElement() {
this.getParent() instanceof GwtUiTemplateXmlFile and this.getParent() instanceof GwtUiTemplateXmlFile and
this.getName() = "UiBinder" and this.getName() = "UiBinder" and
this.getNamespace().getURI() = "urn:ui:com.google.gwt.uibinder" this.getNamespace().getUri() = "urn:ui:com.google.gwt.uibinder"
} }
} }
@@ -27,7 +27,7 @@ class GwtUiBinderTemplateElement extends XmlElement {
class GwtComponentTemplateElement extends XmlElement { class GwtComponentTemplateElement extends XmlElement {
GwtComponentTemplateElement() { GwtComponentTemplateElement() {
exists(GwtUiBinderTemplateElement templateElement | this = templateElement.getAChild*() | exists(GwtUiBinderTemplateElement templateElement | this = templateElement.getAChild*() |
this.getNamespace().getURI().substring(0, 10) = "urn:import" this.getNamespace().getUri().substring(0, 10) = "urn:import"
) )
} }
@@ -36,7 +36,7 @@ class GwtComponentTemplateElement extends XmlElement {
*/ */
Class getClass() { Class getClass() {
exists(string namespace | exists(string namespace |
namespace = this.getNamespace().getURI() and namespace = this.getNamespace().getUri() and
result.getQualifiedName() = namespace.substring(11, namespace.length()) + "." + this.getName() result.getQualifiedName() = namespace.substring(11, namespace.length()) + "." + this.getName()
) )
} }

View File

@@ -7,8 +7,8 @@ import java
/** /**
* An Objective-C Native Interface (OCNI) comment. * An Objective-C Native Interface (OCNI) comment.
*/ */
class OCNIComment extends Javadoc { class OcniComment extends Javadoc {
OCNIComment() { OcniComment() {
// The comment must start with `-[` ... // The comment must start with `-[` ...
this.getChild(0).getText().matches("-[%") and this.getChild(0).getText().matches("-[%") and
// ... and it must end with `]-`. // ... and it must end with `]-`.
@@ -16,8 +16,11 @@ class OCNIComment extends Javadoc {
} }
} }
/** DEPRECATED: Alias for OcniComment */
deprecated class OCNIComment = OcniComment;
/** Auxiliary predicate: `ocni` is an OCNI comment associated with method `m`. */ /** Auxiliary predicate: `ocni` is an OCNI comment associated with method `m`. */
private predicate ocniComment(OCNIComment ocni, Method m) { private predicate ocniComment(OcniComment ocni, Method m) {
// The associated callable must be marked as `native` ... // The associated callable must be marked as `native` ...
m.isNative() and m.isNative() and
// ... and the comment has to be contained in `m`. // ... and the comment has to be contained in `m`.
@@ -30,21 +33,27 @@ private predicate ocniComment(OCNIComment ocni, Method m) {
* An Objective-C Native Interface (OCNI) comment that contains Objective-C code * An Objective-C Native Interface (OCNI) comment that contains Objective-C code
* implementing a native method. * implementing a native method.
*/ */
class OCNIMethodComment extends OCNIComment { class OcniMethodComment extends OcniComment {
OCNIMethodComment() { ocniComment(this, _) } OcniMethodComment() { ocniComment(this, _) }
/** Gets the method implemented by this comment. */ /** Gets the method implemented by this comment. */
Method getImplementedMethod() { ocniComment(this, result) } Method getImplementedMethod() { ocniComment(this, result) }
} }
/** DEPRECATED: Alias for OcniMethodComment */
deprecated class OCNIMethodComment = OcniMethodComment;
/** /**
* An Objective-C Native Interface (OCNI) native import comment. * An Objective-C Native Interface (OCNI) native import comment.
*/ */
class OCNIImport extends OCNIComment { class OcniImport extends OcniComment {
OCNIImport() { OcniImport() {
this.getAChild().getText().regexpMatch(".*#(import|include).*") and this.getAChild().getText().regexpMatch(".*#(import|include).*") and
not exists(RefType rt | rt.getFile() = this.getFile() | not exists(RefType rt | rt.getFile() = this.getFile() |
rt.getLocation().getStartLine() < this.getLocation().getStartLine() rt.getLocation().getStartLine() < this.getLocation().getStartLine()
) )
} }
} }
/** DEPRECATED: Alias for OcniImport */
deprecated class OCNIImport = OcniImport;

View File

@@ -14,8 +14,8 @@ abstract class EJB extends Class {
/** /**
* A session EJB. * A session EJB.
*/ */
class SessionEJB extends EJB { class SessionEjb extends EJB {
SessionEJB() { SessionEjb() {
// Subtype of `javax.ejb.SessionBean`. // Subtype of `javax.ejb.SessionBean`.
this instanceof SessionBean or this instanceof SessionBean or
// EJB annotations. // EJB annotations.
@@ -50,8 +50,8 @@ class SessionEJB extends EJB {
* using either an annotation or an XML deployment descriptor. * using either an annotation or an XML deployment descriptor.
*/ */
private BusinessInterface getAnExplicitBusinessInterface() { private BusinessInterface getAnExplicitBusinessInterface() {
result.(AnnotatedBusinessInterface).getAnEJB() = this or result.(AnnotatedBusinessInterface).getAnEjb() = this or
result.(XmlSpecifiedBusinessInterface).getAnEJB() = this result.(XmlSpecifiedBusinessInterface).getAnEjb() = this
} }
/** /**
@@ -69,40 +69,40 @@ class SessionEJB extends EJB {
LegacyEjbRemoteInterface getARemoteInterface() { LegacyEjbRemoteInterface getARemoteInterface() {
result = this.getASupertype() and result instanceof ExtendedRemoteInterface result = this.getASupertype() and result instanceof ExtendedRemoteInterface
or or
exists(AnnotatedRemoteHomeInterface i | i.getAnEJB() = this | exists(AnnotatedRemoteHomeInterface i | i.getAnEjb() = this |
result = i.getAnAssociatedRemoteInterface() result = i.getAnAssociatedRemoteInterface()
) )
or or
result.(XmlSpecifiedRemoteInterface).getAnEJB() = this result.(XmlSpecifiedRemoteInterface).getAnEjb() = this
} }
/** Any remote home interfaces of this EJB. */ /** Any remote home interfaces of this EJB. */
LegacyEjbRemoteHomeInterface getARemoteHomeInterface() { LegacyEjbRemoteHomeInterface getARemoteHomeInterface() {
result = this.getASupertype() and result instanceof ExtendedRemoteHomeInterface result = this.getASupertype() and result instanceof ExtendedRemoteHomeInterface
or or
result.(AnnotatedRemoteHomeInterface).getAnEJB() = this result.(AnnotatedRemoteHomeInterface).getAnEjb() = this
or or
result.(XmlSpecifiedRemoteHomeInterface).getAnEJB() = this result.(XmlSpecifiedRemoteHomeInterface).getAnEjb() = this
} }
/** Any local interfaces of this EJB. */ /** Any local interfaces of this EJB. */
LegacyEjbLocalInterface getALocalInterface() { LegacyEjbLocalInterface getALocalInterface() {
result = this.getASupertype() and result instanceof ExtendedLocalInterface result = this.getASupertype() and result instanceof ExtendedLocalInterface
or or
exists(AnnotatedLocalHomeInterface i | i.getAnEJB() = this | exists(AnnotatedLocalHomeInterface i | i.getAnEjb() = this |
result = i.getAnAssociatedLocalInterface() result = i.getAnAssociatedLocalInterface()
) )
or or
result.(XmlSpecifiedLocalInterface).getAnEJB() = this result.(XmlSpecifiedLocalInterface).getAnEjb() = this
} }
/** Any local home interfaces of this EJB. */ /** Any local home interfaces of this EJB. */
LegacyEjbLocalHomeInterface getALocalHomeInterface() { LegacyEjbLocalHomeInterface getALocalHomeInterface() {
result = this.getASupertype() and result instanceof ExtendedLocalHomeInterface result = this.getASupertype() and result instanceof ExtendedLocalHomeInterface
or or
result.(AnnotatedLocalHomeInterface).getAnEJB() = this result.(AnnotatedLocalHomeInterface).getAnEjb() = this
or or
result.(XmlSpecifiedLocalHomeInterface).getAnEJB() = this result.(XmlSpecifiedLocalHomeInterface).getAnEjb() = this
} }
/** Any `ejbCreate*` methods required for legacy remote or local home interfaces. */ /** Any `ejbCreate*` methods required for legacy remote or local home interfaces. */
@@ -112,11 +112,14 @@ class SessionEJB extends EJB {
EjbAnnotatedInitMethod getAnAnnotatedInitMethod() { this.inherits(result) } EjbAnnotatedInitMethod getAnAnnotatedInitMethod() { this.inherits(result) }
} }
/** DEPRECATED: Alias for SessionEjb */
deprecated class SessionEJB = SessionEjb;
/** /**
* A stateful session EJB. * A stateful session EJB.
*/ */
class StatefulSessionEJB extends SessionEJB { class StatefulSessionEjb extends SessionEjb {
StatefulSessionEJB() { StatefulSessionEjb() {
// EJB annotations. // EJB annotations.
this.getAnAnnotation().getType().hasName("Stateful") this.getAnAnnotation().getType().hasName("Stateful")
or or
@@ -129,11 +132,14 @@ class StatefulSessionEJB extends SessionEJB {
} }
} }
/** DEPRECATED: Alias for StatefulSessionEjb */
deprecated class StatefulSessionEJB = StatefulSessionEjb;
/** /**
* A stateless session EJB. * A stateless session EJB.
*/ */
class StatelessSessionEJB extends SessionEJB { class StatelessSessionEjb extends SessionEjb {
StatelessSessionEJB() { StatelessSessionEjb() {
// EJB annotations. // EJB annotations.
this.getAnAnnotation().getType().hasName("Stateless") this.getAnAnnotation().getType().hasName("Stateless")
or or
@@ -146,6 +152,9 @@ class StatelessSessionEJB extends SessionEJB {
} }
} }
/** DEPRECATED: Alias for StatelessSessionEjb */
deprecated class StatelessSessionEJB = StatelessSessionEjb;
/** /**
* A message-driven EJB. * A message-driven EJB.
*/ */
@@ -168,8 +177,8 @@ class MessageDrivenBean extends EJB {
/** /**
* An entity EJB (deprecated as of EJB 3.0). * An entity EJB (deprecated as of EJB 3.0).
*/ */
class EntityEJB extends EJB { class EntityEjb extends EJB {
EntityEJB() { EntityEjb() {
// Subtype of `javax.ejb.EntityBean`. // Subtype of `javax.ejb.EntityBean`.
this instanceof EntityBean this instanceof EntityBean
or or
@@ -181,6 +190,9 @@ class EntityEJB extends EJB {
} }
} }
/** DEPRECATED: Alias for EntityEjb */
deprecated class EntityEJB = EntityEjb;
/* /*
* Business interfaces (applicable to session beans). * Business interfaces (applicable to session beans).
*/ */
@@ -231,7 +243,10 @@ class LocalAnnotation extends BusinessInterfaceAnnotation {
*/ */
abstract class BusinessInterface extends Interface { abstract class BusinessInterface extends Interface {
/** Gets an EJB to which this business interface belongs. */ /** Gets an EJB to which this business interface belongs. */
abstract SessionEJB getAnEJB(); abstract SessionEjb getAnEjb();
/** DEPRECATED: Alias for getAnEjb */
deprecated SessionEJB getAnEJB() { result = this.getAnEjb() }
/** Holds if this business interface is declared local. */ /** Holds if this business interface is declared local. */
abstract predicate isDeclaredLocal(); abstract predicate isDeclaredLocal();
@@ -251,7 +266,7 @@ class XmlSpecifiedBusinessInterface extends BusinessInterface {
) )
} }
override SessionEJB getAnEJB() { override SessionEjb getAnEjb() {
exists(EjbJarXmlFile f, EjbJarSessionElement se | exists(EjbJarXmlFile f, EjbJarSessionElement se |
se = f.getASessionElement() and se = f.getASessionElement() and
this.getQualifiedName() = se.getABusinessElement().getACharactersSet().getCharacters() and this.getQualifiedName() = se.getABusinessElement().getACharactersSet().getCharacters() and
@@ -259,6 +274,9 @@ class XmlSpecifiedBusinessInterface extends BusinessInterface {
) )
} }
/** DEPRECATED: Alias for getAnEjb */
deprecated override SessionEJB getAnEJB() { result = this.getAnEjb() }
override predicate isDeclaredLocal() { override predicate isDeclaredLocal() {
exists(EjbJarXmlFile f | exists(EjbJarXmlFile f |
this.getQualifiedName() = this.getQualifiedName() =
@@ -291,10 +309,13 @@ class AnnotatedBusinessInterface extends BusinessInterface {
* Any class that has a `@Local` or `@Remote` annotation that names this interface * Any class that has a `@Local` or `@Remote` annotation that names this interface
* is an EJB to which this business interface belongs. * is an EJB to which this business interface belongs.
*/ */
override SessionEJB getAnEJB() { override SessionEjb getAnEjb() {
result.getAnAnnotation().(BusinessInterfaceAnnotation).getANamedType() = this result.getAnAnnotation().(BusinessInterfaceAnnotation).getANamedType() = this
} }
/** DEPRECATED: Alias for getAnEjb */
deprecated override SessionEJB getAnEJB() { result = this.getAnEjb() }
override predicate isDeclaredLocal() { this instanceof LocalAnnotatedBusinessInterface } override predicate isDeclaredLocal() { this instanceof LocalAnnotatedBusinessInterface }
override predicate isDeclaredRemote() { this instanceof RemoteAnnotatedBusinessInterface } override predicate isDeclaredRemote() { this instanceof RemoteAnnotatedBusinessInterface }
@@ -338,7 +359,7 @@ class InitAnnotation extends Annotation {
class EjbAnnotatedInitMethod extends Method { class EjbAnnotatedInitMethod extends Method {
EjbAnnotatedInitMethod() { EjbAnnotatedInitMethod() {
this.getAnAnnotation() instanceof InitAnnotation and this.getAnAnnotation() instanceof InitAnnotation and
exists(SessionEJB ejb | ejb.inherits(this)) exists(SessionEjb ejb | ejb.inherits(this))
} }
} }
@@ -349,7 +370,7 @@ class EjbAnnotatedInitMethod extends Method {
class EjbCreateMethod extends Method { class EjbCreateMethod extends Method {
EjbCreateMethod() { EjbCreateMethod() {
this.getName().matches("ejbCreate%") and this.getName().matches("ejbCreate%") and
exists(SessionEJB ejb | ejb.inherits(this)) exists(SessionEjb ejb | ejb.inherits(this))
} }
/** Gets the suffix of the method name without the `ejbCreate` prefix. */ /** Gets the suffix of the method name without the `ejbCreate` prefix. */
@@ -405,8 +426,8 @@ abstract class LegacyEjbHomeInterface extends LegacyEjbInterface {
/** A legacy remote interface. */ /** A legacy remote interface. */
abstract class LegacyEjbRemoteInterface extends LegacyEjbInterface { } abstract class LegacyEjbRemoteInterface extends LegacyEjbInterface { }
/** A legacy remote interface that extends `javax.ejb.EJBObject`. */ /** A legacy remote interface that extends `javax.ejb.EjbObject`. */
class ExtendedRemoteInterface extends LegacyEjbRemoteInterface, RemoteEJBInterface { } class ExtendedRemoteInterface extends LegacyEjbRemoteInterface, RemoteEjbInterface { }
/** A legacy remote interface specified within an XML deployment descriptor. */ /** A legacy remote interface specified within an XML deployment descriptor. */
class XmlSpecifiedRemoteInterface extends LegacyEjbRemoteInterface { class XmlSpecifiedRemoteInterface extends LegacyEjbRemoteInterface {
@@ -421,20 +442,23 @@ class XmlSpecifiedRemoteInterface extends LegacyEjbRemoteInterface {
* Gets a session EJB specified in the XML deployment descriptor * Gets a session EJB specified in the XML deployment descriptor
* for this legacy EJB remote interface. * for this legacy EJB remote interface.
*/ */
SessionEJB getAnEJB() { SessionEjb getAnEjb() {
exists(EjbJarXmlFile f, EjbJarSessionElement se | exists(EjbJarXmlFile f, EjbJarSessionElement se |
se = f.getASessionElement() and se = f.getASessionElement() and
this.getQualifiedName() = se.getARemoteElement().getACharactersSet().getCharacters() and this.getQualifiedName() = se.getARemoteElement().getACharactersSet().getCharacters() and
result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters()
) )
} }
/** DEPRECATED: Alias for getAnEjb */
deprecated SessionEJB getAnEJB() { result = this.getAnEjb() }
} }
/** A legacy remote home interface. */ /** A legacy remote home interface. */
abstract class LegacyEjbRemoteHomeInterface extends LegacyEjbHomeInterface { } abstract class LegacyEjbRemoteHomeInterface extends LegacyEjbHomeInterface { }
/** A legacy remote home interface that extends `javax.ejb.EJBHome`. */ /** A legacy remote home interface that extends `javax.ejb.EjbHome`. */
class ExtendedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface, RemoteEJBHomeInterface { } class ExtendedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface, RemoteEjbHomeInterface { }
/** A legacy remote home interface specified by means of a `@RemoteHome` annotation. */ /** A legacy remote home interface specified by means of a `@RemoteHome` annotation. */
class AnnotatedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface { class AnnotatedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface {
@@ -444,7 +468,10 @@ class AnnotatedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface {
} }
/** Gets an EJB to which this interface belongs. */ /** Gets an EJB to which this interface belongs. */
SessionEJB getAnEJB() { result.getAnAnnotation().(RemoteHomeAnnotation).getANamedType() = this } SessionEjb getAnEjb() { result.getAnAnnotation().(RemoteHomeAnnotation).getANamedType() = this }
/** DEPRECATED: Alias for getAnEjb */
deprecated SessionEJB getAnEJB() { result = this.getAnEjb() }
/** Gets a remote interface associated with this legacy remote home interface. */ /** Gets a remote interface associated with this legacy remote home interface. */
Interface getAnAssociatedRemoteInterface() { result = this.getACreateMethod().getReturnType() } Interface getAnAssociatedRemoteInterface() { result = this.getACreateMethod().getReturnType() }
@@ -460,20 +487,23 @@ class XmlSpecifiedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface {
} }
/** Gets an EJB to which this interface belongs. */ /** Gets an EJB to which this interface belongs. */
SessionEJB getAnEJB() { SessionEjb getAnEjb() {
exists(EjbJarXmlFile f, EjbJarSessionElement se | exists(EjbJarXmlFile f, EjbJarSessionElement se |
se = f.getASessionElement() and se = f.getASessionElement() and
this.getQualifiedName() = se.getARemoteHomeElement().getACharactersSet().getCharacters() and this.getQualifiedName() = se.getARemoteHomeElement().getACharactersSet().getCharacters() and
result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters()
) )
} }
/** DEPRECATED: Alias for getAnEjb */
deprecated SessionEJB getAnEJB() { result = this.getAnEjb() }
} }
/** A legacy local interface. */ /** A legacy local interface. */
abstract class LegacyEjbLocalInterface extends LegacyEjbInterface { } abstract class LegacyEjbLocalInterface extends LegacyEjbInterface { }
/** A legacy local interface that extends `javax.ejb.EJBLocalObject`. */ /** A legacy local interface that extends `javax.ejb.EJBLocalObject`. */
class ExtendedLocalInterface extends LegacyEjbLocalInterface, LocalEJBInterface { } class ExtendedLocalInterface extends LegacyEjbLocalInterface, LocalEjbInterface { }
/** A legacy local interface specified within an XML deployment descriptor. */ /** A legacy local interface specified within an XML deployment descriptor. */
class XmlSpecifiedLocalInterface extends LegacyEjbLocalInterface { class XmlSpecifiedLocalInterface extends LegacyEjbLocalInterface {
@@ -485,20 +515,23 @@ class XmlSpecifiedLocalInterface extends LegacyEjbLocalInterface {
} }
/** Gets an EJB to which this interface belongs. */ /** Gets an EJB to which this interface belongs. */
SessionEJB getAnEJB() { SessionEjb getAnEjb() {
exists(EjbJarXmlFile f, EjbJarSessionElement se | exists(EjbJarXmlFile f, EjbJarSessionElement se |
se = f.getASessionElement() and se = f.getASessionElement() and
this.getQualifiedName() = se.getALocalElement().getACharactersSet().getCharacters() and this.getQualifiedName() = se.getALocalElement().getACharactersSet().getCharacters() and
result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters()
) )
} }
/** DEPRECATED: Alias for getAnEjb */
deprecated SessionEJB getAnEJB() { result = this.getAnEjb() }
} }
/** A legacy local home interface. */ /** A legacy local home interface. */
abstract class LegacyEjbLocalHomeInterface extends LegacyEjbHomeInterface { } abstract class LegacyEjbLocalHomeInterface extends LegacyEjbHomeInterface { }
/** A legacy local home interface that extends `javax.ejb.EJBLocalHome`. */ /** A legacy local home interface that extends `javax.ejb.EJBLocalHome`. */
class ExtendedLocalHomeInterface extends LegacyEjbLocalHomeInterface, LocalEJBHomeInterface { } class ExtendedLocalHomeInterface extends LegacyEjbLocalHomeInterface, LocalEjbHomeInterface { }
/** A legacy local home interface specified by means of a `@LocalHome` annotation. */ /** A legacy local home interface specified by means of a `@LocalHome` annotation. */
class AnnotatedLocalHomeInterface extends LegacyEjbLocalHomeInterface { class AnnotatedLocalHomeInterface extends LegacyEjbLocalHomeInterface {
@@ -508,7 +541,10 @@ class AnnotatedLocalHomeInterface extends LegacyEjbLocalHomeInterface {
} }
/** Gets an EJB to which this interface belongs. */ /** Gets an EJB to which this interface belongs. */
SessionEJB getAnEJB() { result.getAnAnnotation().(LocalHomeAnnotation).getANamedType() = this } SessionEjb getAnEjb() { result.getAnAnnotation().(LocalHomeAnnotation).getANamedType() = this }
/** DEPRECATED: Alias for getAnEjb */
deprecated SessionEJB getAnEJB() { result = this.getAnEjb() }
/** Gets a local interface associated with this legacy local home interface. */ /** Gets a local interface associated with this legacy local home interface. */
Interface getAnAssociatedLocalInterface() { result = this.getACreateMethod().getReturnType() } Interface getAnAssociatedLocalInterface() { result = this.getACreateMethod().getReturnType() }
@@ -524,13 +560,16 @@ class XmlSpecifiedLocalHomeInterface extends LegacyEjbLocalHomeInterface {
} }
/** Gets an EJB to which this interface belongs. */ /** Gets an EJB to which this interface belongs. */
SessionEJB getAnEJB() { SessionEjb getAnEjb() {
exists(EjbJarXmlFile f, EjbJarSessionElement se | exists(EjbJarXmlFile f, EjbJarSessionElement se |
se = f.getASessionElement() and se = f.getASessionElement() and
this.getQualifiedName() = se.getALocalHomeElement().getACharactersSet().getCharacters() and this.getQualifiedName() = se.getALocalHomeElement().getACharactersSet().getCharacters() and
result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters() result.getQualifiedName() = se.getAnEjbClassElement().getACharactersSet().getCharacters()
) )
} }
/** DEPRECATED: Alias for getAnEjb */
deprecated SessionEJB getAnEJB() { result = this.getAnEjb() }
} }
/** /**
@@ -541,19 +580,22 @@ class RemoteInterface extends Interface {
RemoteInterface() { RemoteInterface() {
this instanceof RemoteAnnotatedBusinessInterface or this instanceof RemoteAnnotatedBusinessInterface or
this.(XmlSpecifiedBusinessInterface).isDeclaredRemote() or this.(XmlSpecifiedBusinessInterface).isDeclaredRemote() or
exists(SessionEJB ejb | this = ejb.getARemoteInterface()) exists(SessionEjb ejb | this = ejb.getARemoteInterface())
} }
/** /**
* Any EJBs associated with this `RemoteInterface` * Any EJBs associated with this `RemoteInterface`
* by means of annotations or `ejb-jar.xml` configuration files. * by means of annotations or `ejb-jar.xml` configuration files.
*/ */
SessionEJB getAnEJB() { SessionEjb getAnEjb() {
result.getAnAnnotation().(RemoteAnnotation).getANamedType() = this or result.getAnAnnotation().(RemoteAnnotation).getANamedType() = this or
result = this.(XmlSpecifiedRemoteInterface).getAnEJB() or result = this.(XmlSpecifiedRemoteInterface).getAnEjb() or
result.getARemoteInterface() = this result.getARemoteInterface() = this
} }
/** DEPRECATED: Alias for getAnEjb */
deprecated SessionEJB getAnEJB() { result = this.getAnEjb() }
/** /**
* A "remote method" is a method that is available on the remote * A "remote method" is a method that is available on the remote
* interface (either because it's declared or inherited). * interface (either because it's declared or inherited).
@@ -585,8 +627,8 @@ class RemoteInterface extends Interface {
* but the EJB is not a subtype of this remote interface. * but the EJB is not a subtype of this remote interface.
*/ */
Method getARemoteMethodImplementationUnchecked() { Method getARemoteMethodImplementationUnchecked() {
exists(SessionEJB ejb, Method rm | exists(SessionEjb ejb, Method rm |
ejb = this.getAnEJB() and ejb = this.getAnEjb() and
not ejb.getAnAncestor() = this and not ejb.getAnAncestor() = this and
rm = this.getARemoteMethod() and rm = this.getARemoteMethod() and
result = getAnInheritedMatchingMethodIgnoreThrows(ejb, rm.getSignature()) and result = getAnInheritedMatchingMethodIgnoreThrows(ejb, rm.getSignature()) and
@@ -648,13 +690,13 @@ private predicate throwsExplicitUncheckedException(Method m, Exception ex) {
} }
/** Gets a method (inherited by `ejb`) matching the signature `sig`. (Ignores `throws` clauses.) */ /** Gets a method (inherited by `ejb`) matching the signature `sig`. (Ignores `throws` clauses.) */
Method getAnInheritedMatchingMethodIgnoreThrows(SessionEJB ejb, string sig) { Method getAnInheritedMatchingMethodIgnoreThrows(SessionEjb ejb, string sig) {
ejb.inherits(result) and ejb.inherits(result) and
sig = result.getSignature() sig = result.getSignature()
} }
/** Holds if `ejb` inherits a method matching the given signature. (Ignores `throws` clauses.) */ /** Holds if `ejb` inherits a method matching the given signature. (Ignores `throws` clauses.) */
predicate inheritsMatchingMethodIgnoreThrows(SessionEJB ejb, string signature) { predicate inheritsMatchingMethodIgnoreThrows(SessionEjb ejb, string signature) {
exists(getAnInheritedMatchingMethodIgnoreThrows(ejb, signature)) exists(getAnInheritedMatchingMethodIgnoreThrows(ejb, signature))
} }
@@ -662,7 +704,7 @@ predicate inheritsMatchingMethodIgnoreThrows(SessionEJB ejb, string signature) {
* If `ejb` inherits a method matching the signature of `m` except for the `throws` clause, * If `ejb` inherits a method matching the signature of `m` except for the `throws` clause,
* then return any type in the `throws` clause that does not match. * then return any type in the `throws` clause that does not match.
*/ */
Type inheritsMatchingMethodExceptThrows(SessionEJB ejb, Method m) { Type inheritsMatchingMethodExceptThrows(SessionEjb ejb, Method m) {
exists(Method n, string sig | exists(Method n, string sig |
ejb.inherits(n) and ejb.inherits(n) and
sig = n.getSignature() and sig = n.getSignature() and
@@ -679,7 +721,7 @@ Type inheritsMatchingMethodExceptThrows(SessionEJB ejb, Method m) {
* (Ignores `throws` clauses.) * (Ignores `throws` clauses.)
*/ */
predicate inheritsMatchingCreateMethodIgnoreThrows( predicate inheritsMatchingCreateMethodIgnoreThrows(
StatefulSessionEJB ejb, EjbInterfaceCreateMethod icm StatefulSessionEjb ejb, EjbInterfaceCreateMethod icm
) { ) {
exists(EjbCreateMethod cm | cm = ejb.getAnEjbCreateMethod() | exists(EjbCreateMethod cm | cm = ejb.getAnEjbCreateMethod() |
cm.getMethodSuffix() = icm.getMethodSuffix() and cm.getMethodSuffix() = icm.getMethodSuffix() and
@@ -705,7 +747,7 @@ predicate inheritsMatchingCreateMethodIgnoreThrows(
* If `ejb` inherits an `ejbCreate` or `@Init` method matching `create` method `m` except for the `throws` clause, * If `ejb` inherits an `ejbCreate` or `@Init` method matching `create` method `m` except for the `throws` clause,
* then return any type in the `throws` clause that does not match. * then return any type in the `throws` clause that does not match.
*/ */
Type inheritsMatchingCreateMethodExceptThrows(StatefulSessionEJB ejb, EjbInterfaceCreateMethod icm) { Type inheritsMatchingCreateMethodExceptThrows(StatefulSessionEjb ejb, EjbInterfaceCreateMethod icm) {
exists(EjbCreateMethod cm | cm = ejb.getAnEjbCreateMethod() | exists(EjbCreateMethod cm | cm = ejb.getAnEjbCreateMethod() |
cm.getMethodSuffix() = icm.getMethodSuffix() and cm.getMethodSuffix() = icm.getMethodSuffix() and
cm.getNumberOfParameters() = icm.getNumberOfParameters() and cm.getNumberOfParameters() = icm.getNumberOfParameters() and
@@ -814,10 +856,13 @@ class DependsOnAnnotation extends Annotation {
/** /**
* A `@javax.ejb.EJB` annotation. * A `@javax.ejb.EJB` annotation.
*/ */
class EJBAnnotation extends Annotation { class EjbAnnotation extends Annotation {
EJBAnnotation() { this.getType().hasQualifiedName("javax.ejb", "EJB") } EjbAnnotation() { this.getType().hasQualifiedName("javax.ejb", "EJB") }
} }
/** DEPRECATED: Alias for EjbAnnotation */
deprecated class EJBAnnotation = EjbAnnotation;
/** /**
* A `@javax.ejb.EJBs` annotation. * A `@javax.ejb.EJBs` annotation.
*/ */

View File

@@ -16,7 +16,7 @@ class SpringBean extends SpringXmlElement {
SpringBean() { SpringBean() {
this.getName() = "bean" and this.getName() = "bean" and
// Do not capture Camel beans, which are different // Do not capture Camel beans, which are different
not this.getNamespace().getURI() = "http://camel.apache.org/schema/spring" not this.getNamespace().getUri() = "http://camel.apache.org/schema/spring"
} }
override string toString() { result = this.getBeanIdentifier() } override string toString() { result = this.getBeanIdentifier() }

View File

@@ -10,7 +10,7 @@ import semmle.code.java.frameworks.spring.SpringBean
* An Apache Camel element in a Spring Beans file. * An Apache Camel element in a Spring Beans file.
*/ */
class SpringCamelXmlElement extends SpringXmlElement { class SpringCamelXmlElement extends SpringXmlElement {
SpringCamelXmlElement() { getNamespace().getURI() = "http://camel.apache.org/schema/spring" } SpringCamelXmlElement() { getNamespace().getUri() = "http://camel.apache.org/schema/spring" }
} }
/** DEPRECATED: Alias for SpringCamelXmlElement */ /** DEPRECATED: Alias for SpringCamelXmlElement */
@@ -114,7 +114,10 @@ class SpringCamelXmlToElement extends SpringCamelXmlRouteElement {
/** /**
* Gets the URI attribute for this `<to>` element. * Gets the URI attribute for this `<to>` element.
*/ */
string getURI() { result = getAttribute("uri").getValue() } string getUri() { result = getAttribute("uri").getValue() }
/** DEPRECATED: Alias for getUri */
deprecated string getURI() { result = getUri() }
} }
/** DEPRECATED: Alias for SpringCamelXmlToElement */ /** DEPRECATED: Alias for SpringCamelXmlToElement */

View File

@@ -4,8 +4,8 @@
import java import java
class SSLClass extends RefType { class SslClass extends RefType {
SSLClass() { SslClass() {
exists(Class c | this.getAnAncestor() = c | exists(Class c | this.getAnAncestor() = c |
c.hasQualifiedName("javax.net.ssl", _) or c.hasQualifiedName("javax.net.ssl", _) or
c.hasQualifiedName("javax.rmi.ssl", _) c.hasQualifiedName("javax.rmi.ssl", _)
@@ -13,6 +13,9 @@ class SSLClass extends RefType {
} }
} }
/** DEPRECATED: Alias for SslClass */
deprecated class SSLClass = SslClass;
class X509TrustManager extends RefType { class X509TrustManager extends RefType {
X509TrustManager() { this.hasQualifiedName("javax.net.ssl", "X509TrustManager") } X509TrustManager() { this.hasQualifiedName("javax.net.ssl", "X509TrustManager") }
} }
@@ -25,34 +28,52 @@ class HttpsUrlConnection extends RefType {
/** DEPRECATED: Alias for HttpsUrlConnection */ /** DEPRECATED: Alias for HttpsUrlConnection */
deprecated class HttpsURLConnection = HttpsUrlConnection; deprecated class HttpsURLConnection = HttpsUrlConnection;
class SSLSocketFactory extends RefType { class SslSocketFactory extends RefType {
SSLSocketFactory() { this.hasQualifiedName("javax.net.ssl", "SSLSocketFactory") } SslSocketFactory() { this.hasQualifiedName("javax.net.ssl", "SSLSocketFactory") }
} }
class SSLContext extends RefType { /** DEPRECATED: Alias for SslSocketFactory */
SSLContext() { this.hasQualifiedName("javax.net.ssl", "SSLContext") } deprecated class SSLSocketFactory = SslSocketFactory;
class SslContext extends RefType {
SslContext() { this.hasQualifiedName("javax.net.ssl", "SSLContext") }
} }
/** The `javax.net.ssl.SSLSession` class. */ /** DEPRECATED: Alias for SslContext */
class SSLSession extends RefType { deprecated class SSLContext = SslContext;
SSLSession() { this.hasQualifiedName("javax.net.ssl", "SSLSession") }
/** The `javax.net.ssl.SslSession` class. */
class SslSession extends RefType {
SslSession() { this.hasQualifiedName("javax.net.ssl", "SSLSession") }
} }
/** The `javax.net.ssl.SSLEngine` class. */ /** DEPRECATED: Alias for SslSession */
class SSLEngine extends RefType { deprecated class SSLSession = SslSession;
SSLEngine() { this.hasQualifiedName("javax.net.ssl", "SSLEngine") }
/** The `javax.net.ssl.SslEngine` class. */
class SslEngine extends RefType {
SslEngine() { this.hasQualifiedName("javax.net.ssl", "SSLEngine") }
} }
/** The `javax.net.ssl.SSLSocket` class. */ /** DEPRECATED: Alias for SslEngine */
class SSLSocket extends RefType { deprecated class SSLEngine = SslEngine;
SSLSocket() { this.hasQualifiedName("javax.net.ssl", "SSLSocket") }
/** The `javax.net.ssl.SslSocket` class. */
class SslSocket extends RefType {
SslSocket() { this.hasQualifiedName("javax.net.ssl", "SSLSocket") }
} }
/** The `javax.net.ssl.SSLParameters` class. */ /** DEPRECATED: Alias for SslSocket */
class SSLParameters extends RefType { deprecated class SSLSocket = SslSocket;
SSLParameters() { this.hasQualifiedName("javax.net.ssl", "SSLParameters") }
/** The `javax.net.ssl.SslParameters` class. */
class SslParameters extends RefType {
SslParameters() { this.hasQualifiedName("javax.net.ssl", "SSLParameters") }
} }
/** DEPRECATED: Alias for SslParameters */
deprecated class SSLParameters = SslParameters;
class HostnameVerifier extends RefType { class HostnameVerifier extends RefType {
HostnameVerifier() { this.hasQualifiedName("javax.net.ssl", "HostnameVerifier") } HostnameVerifier() { this.hasQualifiedName("javax.net.ssl", "HostnameVerifier") }
} }
@@ -73,7 +94,7 @@ class HostnameVerifierVerify extends Method {
this.hasName("verify") and this.hasName("verify") and
this.getDeclaringType().getAnAncestor() instanceof HostnameVerifier and this.getDeclaringType().getAnAncestor() instanceof HostnameVerifier and
this.getParameterType(0) instanceof TypeString and this.getParameterType(0) instanceof TypeString and
this.getParameterType(1) instanceof SSLSession this.getParameterType(1) instanceof SslSession
} }
} }
@@ -87,22 +108,22 @@ class TrustManagerCheckMethod extends Method {
class CreateSocket extends Method { class CreateSocket extends Method {
CreateSocket() { CreateSocket() {
this.hasName("createSocket") and this.hasName("createSocket") and
this.getDeclaringType() instanceof SSLSocketFactory this.getDeclaringType() instanceof SslSocketFactory
} }
} }
class GetSocketFactory extends Method { class GetSocketFactory extends Method {
GetSocketFactory() { GetSocketFactory() {
this.hasName("getSocketFactory") and this.hasName("getSocketFactory") and
this.getDeclaringType() instanceof SSLContext this.getDeclaringType() instanceof SslContext
} }
} }
/** The `createSSLEngine` method of the class `javax.net.ssl.SSLContext`. */ /** The `createSSLEngine` method of the class `javax.net.ssl.SslContext`. */
class CreateSslEngineMethod extends Method { class CreateSslEngineMethod extends Method {
CreateSslEngineMethod() { CreateSslEngineMethod() {
this.hasName("createSSLEngine") and this.hasName("createSSLEngine") and
this.getDeclaringType() instanceof SSLContext this.getDeclaringType() instanceof SslContext
} }
} }
@@ -128,35 +149,35 @@ class SetDefaultHostnameVerifierMethod extends Method {
} }
} }
/** The `beginHandshake` method of the class `javax.net.ssl.SSLEngine`. */ /** The `beginHandshake` method of the class `javax.net.ssl.SslEngine`. */
class BeginHandshakeMethod extends Method { class BeginHandshakeMethod extends Method {
BeginHandshakeMethod() { BeginHandshakeMethod() {
this.hasName("beginHandshake") and this.hasName("beginHandshake") and
this.getDeclaringType().getAnAncestor() instanceof SSLEngine this.getDeclaringType().getAnAncestor() instanceof SslEngine
} }
} }
/** The `wrap` method of the class `javax.net.ssl.SSLEngine`. */ /** The `wrap` method of the class `javax.net.ssl.SslEngine`. */
class SslWrapMethod extends Method { class SslWrapMethod extends Method {
SslWrapMethod() { SslWrapMethod() {
this.hasName("wrap") and this.hasName("wrap") and
this.getDeclaringType().getAnAncestor() instanceof SSLEngine this.getDeclaringType().getAnAncestor() instanceof SslEngine
} }
} }
/** The `unwrap` method of the class `javax.net.ssl.SSLEngine`. */ /** The `unwrap` method of the class `javax.net.ssl.SslEngine`. */
class SslUnwrapMethod extends Method { class SslUnwrapMethod extends Method {
SslUnwrapMethod() { SslUnwrapMethod() {
this.hasName("unwrap") and this.hasName("unwrap") and
this.getDeclaringType().getAnAncestor() instanceof SSLEngine this.getDeclaringType().getAnAncestor() instanceof SslEngine
} }
} }
/** The `getSession` method of the class `javax.net.ssl.SSLSession`. */ /** The `getSession` method of the class `javax.net.ssl.SslSession`. */
class GetSslSessionMethod extends Method { class GetSslSessionMethod extends Method {
GetSslSessionMethod() { GetSslSessionMethod() {
this.hasName("getSession") and this.hasName("getSession") and
this.getDeclaringType().getAnAncestor() instanceof SSLSession this.getDeclaringType().getAnAncestor() instanceof SslSession
} }
} }

View File

@@ -126,7 +126,9 @@ class UntrustedExternalApiDataNode extends ExternalApiDataNode {
/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ /** DEPRECATED: Alias for UntrustedExternalApiDataNode */
deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode;
/** An external API which is used with untrusted data. */
private newtype TExternalApi = private newtype TExternalApi =
/** An untrusted API method `m` where untrusted data is passed at `index`. */
TExternalApiParameter(Method m, int index) { TExternalApiParameter(Method m, int index) {
exists(UntrustedExternalApiDataNode n | exists(UntrustedExternalApiDataNode n |
m = n.getMethod() and m = n.getMethod() and

View File

@@ -26,7 +26,7 @@ private class DefaultInsecureTrustManagerSink extends InsecureTrustManagerSink {
DefaultInsecureTrustManagerSink() { DefaultInsecureTrustManagerSink() {
exists(MethodAccess ma, Method m | exists(MethodAccess ma, Method m |
m.hasName("init") and m.hasName("init") and
m.getDeclaringType() instanceof SSLContext and m.getDeclaringType() instanceof SslContext and
ma.getMethod() = m ma.getMethod() = m
| |
ma.getArgument(1) = this.asExpr() ma.getArgument(1) = this.asExpr()

View File

@@ -41,5 +41,5 @@ class SensitiveLoggerConfiguration extends TaintTracking::Configuration {
sanitizer.getType() instanceof TypeType sanitizer.getType() instanceof TypeType
} }
override predicate isSanitizerIn(Node node) { isSource(node) } override predicate isSanitizerIn(Node node) { this.isSource(node) }
} }

View File

@@ -56,7 +56,7 @@ private class SslEngineServerMode extends SslUnsafeCertTrustSanitizer {
SslEngineServerMode() { SslEngineServerMode() {
exists(MethodAccess ma, Method m | exists(MethodAccess ma, Method m |
m.hasName("setUseClientMode") and m.hasName("setUseClientMode") and
m.getDeclaringType().getAnAncestor() instanceof SSLEngine and m.getDeclaringType().getAnAncestor() instanceof SslEngine and
ma.getMethod() = m and ma.getMethod() = m and
ma.getArgument(0).(CompileTimeConstantExpr).getBooleanValue() = false and ma.getArgument(0).(CompileTimeConstantExpr).getBooleanValue() = false and
this.asExpr() = ma.getQualifier() this.asExpr() = ma.getQualifier()
@@ -69,9 +69,9 @@ private class SslEngineServerMode extends SslUnsafeCertTrustSanitizer {
* or the qualifier of `createSocket` is an instance of `SSLSocketFactory`. * or the qualifier of `createSocket` is an instance of `SSLSocketFactory`.
*/ */
private predicate isSslSocket(MethodAccess createSocket) { private predicate isSslSocket(MethodAccess createSocket) {
createSocket = any(CastExpr ce | ce.getType() instanceof SSLSocket).getExpr() createSocket = any(CastExpr ce | ce.getType() instanceof SslSocket).getExpr()
or or
createSocket.getQualifier().getType().(RefType).getAnAncestor() instanceof SSLSocketFactory createSocket.getQualifier().getType().(RefType).getAnAncestor() instanceof SslSocketFactory
} }
/** /**

View File

@@ -44,7 +44,7 @@ private class SafeSslParametersFlowConfig extends DataFlow2::Configuration {
} }
override predicate isSink(DataFlow::Node sink) { override predicate isSink(DataFlow::Node sink) {
exists(MethodAccess ma, RefType t | t instanceof SSLSocket or t instanceof SSLEngine | exists(MethodAccess ma, RefType t | t instanceof SslSocket or t instanceof SslEngine |
ma.getMethod().hasName("setSSLParameters") and ma.getMethod().hasName("setSSLParameters") and
ma.getMethod().getDeclaringType().getAnAncestor() = t and ma.getMethod().getDeclaringType().getAnAncestor() = t and
ma.getArgument(0) = sink.asExpr() ma.getArgument(0) = sink.asExpr()
@@ -58,7 +58,7 @@ private class SafeSslParametersFlowConfig extends DataFlow2::Configuration {
private class SafeSetEndpointIdentificationAlgorithm extends MethodAccess { private class SafeSetEndpointIdentificationAlgorithm extends MethodAccess {
SafeSetEndpointIdentificationAlgorithm() { SafeSetEndpointIdentificationAlgorithm() {
this.getMethod().hasName("setEndpointIdentificationAlgorithm") and this.getMethod().hasName("setEndpointIdentificationAlgorithm") and
this.getMethod().getDeclaringType() instanceof SSLParameters and this.getMethod().getDeclaringType() instanceof SslParameters and
not this.getArgument(0) instanceof NullLiteral and not this.getArgument(0) instanceof NullLiteral and
not this.getArgument(0).(CompileTimeConstantExpr).getStringValue() = "" not this.getArgument(0).(CompileTimeConstantExpr).getStringValue() = ""
} }

View File

@@ -324,7 +324,7 @@ Expr configOptionIsSupportingExternalEntities() {
/** /**
* An `XmlInputFactory` specific expression that indicates whether DTD is supported. * An `XmlInputFactory` specific expression that indicates whether DTD is supported.
*/ */
Expr configOptionSupportDTD() { Expr configOptionSupportDtd() {
result.(ConstantStringExpr).getStringValue() = "javax.xml.stream.supportDTD" result.(ConstantStringExpr).getStringValue() = "javax.xml.stream.supportDTD"
or or
exists(Field f | exists(Field f |
@@ -334,6 +334,9 @@ Expr configOptionSupportDTD() {
) )
} }
/** DEPRECATED: Alias for configOptionSupportDtd */
deprecated Expr configOptionSupportDTD() { result = configOptionSupportDtd() }
/** /**
* A safely configured `XmlInputFactory`. * A safely configured `XmlInputFactory`.
*/ */
@@ -345,7 +348,7 @@ class SafeXmlInputFactory extends VarAccess {
config.disables(configOptionIsSupportingExternalEntities()) config.disables(configOptionIsSupportingExternalEntities())
) and ) and
exists(XmlInputFactoryConfig config | config.getQualifier() = v.getAnAccess() | exists(XmlInputFactoryConfig config | config.getQualifier() = v.getAnAccess() |
config.disables(configOptionSupportDTD()) config.disables(configOptionSupportDtd())
) )
) )
} }
@@ -907,7 +910,7 @@ class XmlConstants extends RefType {
} }
/** A configuration specific for transformers and schema. */ /** A configuration specific for transformers and schema. */
Expr configAccessExternalDTD() { Expr configAccessExternalDtd() {
result.(ConstantStringExpr).getStringValue() = result.(ConstantStringExpr).getStringValue() =
"http://javax.xml.XMLConstants/property/accessExternalDTD" "http://javax.xml.XMLConstants/property/accessExternalDTD"
or or
@@ -918,6 +921,9 @@ Expr configAccessExternalDTD() {
) )
} }
/** DEPRECATED: Alias for configAccessExternalDtd */
deprecated Expr configAccessExternalDTD() { result = configAccessExternalDtd() }
/** A configuration specific for transformers. */ /** A configuration specific for transformers. */
Expr configAccessExternalStyleSheet() { Expr configAccessExternalStyleSheet() {
result.(ConstantStringExpr).getStringValue() = result.(ConstantStringExpr).getStringValue() =
@@ -1040,7 +1046,7 @@ class SafeTransformerFactory extends VarAccess {
SafeTransformerFactory() { SafeTransformerFactory() {
exists(Variable v | v = this.getVariable() | exists(Variable v | v = this.getVariable() |
exists(TransformerFactoryConfig config | config.getQualifier() = v.getAnAccess() | exists(TransformerFactoryConfig config | config.getQualifier() = v.getAnAccess() |
config.disables(configAccessExternalDTD()) config.disables(configAccessExternalDtd())
) and ) and
exists(TransformerFactoryConfig config | config.getQualifier() = v.getAnAccess() | exists(TransformerFactoryConfig config | config.getQualifier() = v.getAnAccess() |
config.disables(configAccessExternalStyleSheet()) config.disables(configAccessExternalStyleSheet())
@@ -1141,7 +1147,7 @@ class SafeSchemaFactory extends VarAccess {
SafeSchemaFactory() { SafeSchemaFactory() {
exists(Variable v | v = this.getVariable() | exists(Variable v | v = this.getVariable() |
exists(SchemaFactoryConfig config | config.getQualifier() = v.getAnAccess() | exists(SchemaFactoryConfig config | config.getQualifier() = v.getAnAccess() |
config.disables(configAccessExternalDTD()) config.disables(configAccessExternalDtd())
) and ) and
exists(SchemaFactoryConfig config | config.getQualifier() = v.getAnAccess() | exists(SchemaFactoryConfig config | config.getQualifier() = v.getAnAccess() |
config.disables(configAccessExternalSchema()) config.disables(configAccessExternalSchema())

View File

@@ -132,7 +132,10 @@ class XmlFile extends XmlParent, File {
XmlElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XmlDTD getADTD() { xmlDTDs(result, _, _, _, this) } XmlDtd getADtd() { xmlDTDs(result, _, _, _, this) }
/** DEPRECATED: Alias for getADtd */
deprecated XmlDtd getADTD() { result = this.getADtd() }
} }
/** DEPRECATED: Alias for XmlFile */ /** DEPRECATED: Alias for XmlFile */
@@ -149,7 +152,7 @@ deprecated class XMLFile = XmlFile;
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XmlDTD extends XmlLocatable, @xmldtd { class XmlDtd extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -174,8 +177,8 @@ class XmlDTD extends XmlLocatable, @xmldtd {
} }
} }
/** DEPRECATED: Alias for XmlDTD */ /** DEPRECATED: Alias for XmlDtd */
deprecated class XMLDTD = XmlDTD; deprecated class XMLDTD = XmlDtd;
/** /**
* An XML element in an XML file. * An XML element in an XML file.
@@ -282,15 +285,18 @@ class XmlNamespace extends XmlLocatable, @xmlnamespace {
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
/** Gets the URI of this namespace. */ /** Gets the URI of this namespace. */
string getURI() { xmlNs(this, _, result, _) } string getUri() { xmlNs(this, _, result, _) }
/** DEPRECATED: Alias for getUri */
deprecated string getURI() { result = this.getUri() }
/** Holds if this namespace has no prefix. */ /** Holds if this namespace has no prefix. */
predicate isDefault() { this.getPrefix() = "" } predicate isDefault() { this.getPrefix() = "" }
override string toString() { override string toString() {
this.isDefault() and result = this.getURI() this.isDefault() and result = this.getUri()
or or
not this.isDefault() and result = this.getPrefix() + ":" + this.getURI() not this.isDefault() and result = this.getPrefix() + ":" + this.getUri()
} }
} }

View File

@@ -81,7 +81,7 @@ predicate exceptions(Class c, Field f) {
// Stateless session beans are not normally serialized during their usual life-cycle // Stateless session beans are not normally serialized during their usual life-cycle
// but are forced by their expected supertype to be serializable. // but are forced by their expected supertype to be serializable.
// Arguably, warnings for their non-serializable fields can therefore be suppressed in practice. // Arguably, warnings for their non-serializable fields can therefore be suppressed in practice.
c instanceof StatelessSessionEJB c instanceof StatelessSessionEjb
or or
// Enum types are serialized by name, so it doesn't matter if they have non-serializable fields. // Enum types are serialized by name, so it doesn't matter if they have non-serializable fields.
c instanceof EnumType c instanceof EnumType

View File

@@ -33,10 +33,10 @@ where
or or
c instanceof Socket and type = "socket" c instanceof Socket and type = "socket"
) and ) and
not c instanceof SSLClass and not c instanceof SslClass and
not exists(RefType t | not exists(RefType t |
exprTypeFlow(m.getQualifier(), t, _) and exprTypeFlow(m.getQualifier(), t, _) and
t instanceof SSLClass t instanceof SslClass
) and ) and
( (
m.getMethod().getName() = "getInputStream" or m.getMethod().getName() = "getInputStream" or

View File

@@ -65,7 +65,7 @@ predicate query(MethodAccess m, Method def, int paramNo, string message, Element
// an SSL factory, ... // an SSL factory, ...
usesFactory(def, paramNo) and usesFactory(def, paramNo) and
evidence = m.getArgument(paramNo) and evidence = m.getArgument(paramNo) and
not evidence.(Expr).getType() instanceof SSLClass and not evidence.(Expr).getType() instanceof SslClass and
message = "has a non-SSL factory argument " message = "has a non-SSL factory argument "
or or
// ... or there is an overloaded method on the same type that does take a factory, // ... or there is an overloaded method on the same type that does take a factory,

View File

@@ -107,8 +107,8 @@ class CommentedOutCode extends JavadocFirst {
CommentedOutCode() { CommentedOutCode() {
anyCount(this) > 0 and anyCount(this) > 0 and
codeCount(this).(float) / anyCount(this).(float) > 0.5 and codeCount(this).(float) / anyCount(this).(float) > 0.5 and
not this instanceof JSNIComment and not this instanceof JsniComment and
not this instanceof OCNIComment not this instanceof OcniComment
} }
/** /**

View File

@@ -87,7 +87,7 @@ predicate isTestMethod(MethodAccess ma) {
} }
/** Holds if `MethodAccess` ma disables SSL endpoint check. */ /** Holds if `MethodAccess` ma disables SSL endpoint check. */
predicate isInsecureSSLEndpoint(MethodAccess ma) { predicate isInsecureSslEndpoint(MethodAccess ma) {
( (
ma.getMethod() instanceof SetSystemPropertyMethod and ma.getMethod() instanceof SetSystemPropertyMethod and
isPropertyDisableLdapEndpointId(ma.getArgument(0)) and isPropertyDisableLdapEndpointId(ma.getArgument(0)) and
@@ -105,6 +105,6 @@ predicate isInsecureSSLEndpoint(MethodAccess ma) {
from MethodAccess ma from MethodAccess ma
where where
isInsecureSSLEndpoint(ma) and isInsecureSslEndpoint(ma) and
not isTestMethod(ma) not isTestMethod(ma)
select ma, "LDAPS configuration allows insecure endpoint identification" select ma, "LDAPS configuration allows insecure endpoint identification"

View File

@@ -27,7 +27,7 @@ class UnsafeTlsVersionConfig extends TaintTracking::Configuration {
class SslContextGetInstanceSink extends DataFlow::ExprNode { class SslContextGetInstanceSink extends DataFlow::ExprNode {
SslContextGetInstanceSink() { SslContextGetInstanceSink() {
exists(StaticMethodAccess ma, Method m | m = ma.getMethod() | exists(StaticMethodAccess ma, Method m | m = ma.getMethod() |
m.getDeclaringType() instanceof SSLContext and m.getDeclaringType() instanceof SslContext and
m.hasName("getInstance") and m.hasName("getInstance") and
ma.getArgument(0) = asExpr() ma.getArgument(0) = asExpr()
) )
@@ -40,7 +40,7 @@ class SslContextGetInstanceSink extends DataFlow::ExprNode {
*/ */
class CreateSslParametersSink extends DataFlow::ExprNode { class CreateSslParametersSink extends DataFlow::ExprNode {
CreateSslParametersSink() { CreateSslParametersSink() {
exists(ConstructorCall cc | cc.getConstructedType() instanceof SSLParameters | exists(ConstructorCall cc | cc.getConstructedType() instanceof SslParameters |
cc.getArgument(1) = asExpr() cc.getArgument(1) = asExpr()
) )
} }
@@ -53,7 +53,7 @@ class CreateSslParametersSink extends DataFlow::ExprNode {
class SslParametersSetProtocolsSink extends DataFlow::ExprNode { class SslParametersSetProtocolsSink extends DataFlow::ExprNode {
SslParametersSetProtocolsSink() { SslParametersSetProtocolsSink() {
exists(MethodAccess ma, Method m | m = ma.getMethod() | exists(MethodAccess ma, Method m | m = ma.getMethod() |
m.getDeclaringType() instanceof SSLParameters and m.getDeclaringType() instanceof SslParameters and
m.hasName("setProtocols") and m.hasName("setProtocols") and
ma.getArgument(0) = asExpr() ma.getArgument(0) = asExpr()
) )
@@ -70,9 +70,9 @@ class SetEnabledProtocolsSink extends DataFlow::ExprNode {
m = ma.getMethod() and type = m.getDeclaringType() m = ma.getMethod() and type = m.getDeclaringType()
| |
( (
type instanceof SSLSocket or type instanceof SslSocket or
type instanceof SSLServerSocket or type instanceof SslServerSocket or
type instanceof SSLEngine type instanceof SslEngine
) and ) and
m.hasName("setEnabledProtocols") and m.hasName("setEnabledProtocols") and
ma.getArgument(0) = asExpr() ma.getArgument(0) = asExpr()
@@ -94,6 +94,6 @@ class UnsafeTlsVersion extends StringLiteral {
} }
} }
class SSLServerSocket extends RefType { class SslServerSocket extends RefType {
SSLServerSocket() { hasQualifiedName("javax.net.ssl", "SSLServerSocket") } SslServerSocket() { hasQualifiedName("javax.net.ssl", "SSLServerSocket") }
} }

View File

@@ -125,7 +125,7 @@ predicate isBasicAuthEnv(MethodAccess ma) {
/** /**
* Holds if `ma` sets `java.naming.security.protocol` (also known as `Context.SECURITY_PROTOCOL`) to `ssl` in some `Hashtable`. * Holds if `ma` sets `java.naming.security.protocol` (also known as `Context.SECURITY_PROTOCOL`) to `ssl` in some `Hashtable`.
*/ */
predicate isSSLEnv(MethodAccess ma) { predicate isSslEnv(MethodAccess ma) {
hasFieldValueEnv(ma, "java.naming.security.protocol", "ssl") or hasFieldValueEnv(ma, "java.naming.security.protocol", "ssl") or
hasFieldNameEnv(ma, "SECURITY_PROTOCOL", "ssl") hasFieldNameEnv(ma, "SECURITY_PROTOCOL", "ssl")
} }
@@ -182,13 +182,13 @@ class BasicAuthFlowConfig extends DataFlow::Configuration {
/** /**
* A taint-tracking configuration for `ssl` configuration in LDAP authentication. * A taint-tracking configuration for `ssl` configuration in LDAP authentication.
*/ */
class SSLFlowConfig extends DataFlow::Configuration { class SslFlowConfig extends DataFlow::Configuration {
SSLFlowConfig() { this = "InsecureLdapAuth:SSLFlowConfig" } SslFlowConfig() { this = "InsecureLdapAuth:SSLFlowConfig" }
/** Source of `ssl` configuration. */ /** Source of `ssl` configuration. */
override predicate isSource(DataFlow::Node src) { override predicate isSource(DataFlow::Node src) {
exists(MethodAccess ma | exists(MethodAccess ma |
isSSLEnv(ma) and ma.getQualifier() = src.(PostUpdateNode).getPreUpdateNode().asExpr() isSslEnv(ma) and ma.getQualifier() = src.(PostUpdateNode).getPreUpdateNode().asExpr()
) )
} }
@@ -205,6 +205,6 @@ from DataFlow::PathNode source, DataFlow::PathNode sink, InsecureUrlFlowConfig c
where where
config.hasFlowPath(source, sink) and config.hasFlowPath(source, sink) and
exists(BasicAuthFlowConfig bc | bc.hasFlowTo(sink.getNode())) and exists(BasicAuthFlowConfig bc | bc.hasFlowTo(sink.getNode())) and
not exists(SSLFlowConfig sc | sc.hasFlowTo(sink.getNode())) not exists(SslFlowConfig sc | sc.hasFlowTo(sink.getNode()))
select sink.getNode(), source, sink, "Insecure LDAP authentication from $@.", source.getNode(), select sink.getNode(), source, sink, "Insecure LDAP authentication from $@.", source.getNode(),
"LDAP connection string" "LDAP connection string"

View File

@@ -25,7 +25,7 @@ class UnsafeUrlForwardFlowConfig extends TaintTracking::Configuration {
source instanceof RemoteFlowSource and source instanceof RemoteFlowSource and
not exists(MethodAccess ma, Method m | ma.getMethod() = m | not exists(MethodAccess ma, Method m | ma.getMethod() = m |
( (
m instanceof HttpServletRequestGetRequestURIMethod or m instanceof HttpServletRequestGetRequestUriMethod or
m instanceof HttpServletRequestGetRequestUrlMethod or m instanceof HttpServletRequestGetRequestUrlMethod or
m instanceof HttpServletRequestGetPathMethod m instanceof HttpServletRequestGetPathMethod
) and ) and

View File

@@ -73,7 +73,7 @@ class SafeValidator extends VarAccess {
SafeValidator() { SafeValidator() {
exists(Variable v | v = this.getVariable() | exists(Variable v | v = this.getVariable() |
exists(ValidatorConfig config | config.getQualifier() = v.getAnAccess() | exists(ValidatorConfig config | config.getQualifier() = v.getAnAccess() |
config.disables(configAccessExternalDTD()) config.disables(configAccessExternalDtd())
) and ) and
exists(ValidatorConfig config | config.getQualifier() = v.getAnAccess() | exists(ValidatorConfig config | config.getQualifier() = v.getAnAccess() |
config.disables(configAccessExternalSchema()) config.disables(configAccessExternalSchema())

View File

@@ -1,5 +1,5 @@
import java import java
import semmle.code.java.frameworks.gwt.GWT import semmle.code.java.frameworks.gwt.GWT
from JSNIComment jsni from JsniComment jsni
select jsni, jsni.getImplementedMethod() select jsni, jsni.getImplementedMethod()

View File

@@ -1,13 +1,13 @@
| IosRSASignature | 39 | 1 | 60 | 4 | /* -[ ... */ | OCNIImport | | IosRSASignature | 39 | 1 | 60 | 4 | /* -[ ... */ | OcniImport |
| IosRSASignature | 78 | 62 | 80 | 6 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 78 | 62 | 80 | 6 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 137 | 3 | 173 | 6 | /* -[ ... */ | OCNIComment | | IosRSASignature | 137 | 3 | 173 | 6 | /* -[ ... */ | OcniComment |
| IosRSASignature | 177 | 62 | 189 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 177 | 62 | 189 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 192 | 82 | 205 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 192 | 82 | 205 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 210 | 62 | 222 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 210 | 62 | 222 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 225 | 82 | 238 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 225 | 82 | 238 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 243 | 62 | 255 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 243 | 62 | 255 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 258 | 82 | 271 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 258 | 82 | 271 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 276 | 62 | 288 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 276 | 62 | 288 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 291 | 82 | 304 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 291 | 82 | 304 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 309 | 62 | 321 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 309 | 62 | 321 | 8 | /* -[ ... */ | OcniMethodComment |
| IosRSASignature | 324 | 82 | 337 | 8 | /* -[ ... */ | OCNIMethodComment | | IosRSASignature | 324 | 82 | 337 | 8 | /* -[ ... */ | OcniMethodComment |

View File

@@ -1,6 +1,6 @@
import semmle.code.java.frameworks.j2objc.J2ObjC import semmle.code.java.frameworks.j2objc.J2ObjC
from OCNIComment ocni from OcniComment ocni
select ocni.getFile().getStem(), ocni.getLocation().getStartLine(), select ocni.getFile().getStem(), ocni.getLocation().getStartLine(),
ocni.getLocation().getStartColumn(), ocni.getLocation().getEndLine(), ocni.getLocation().getStartColumn(), ocni.getLocation().getEndLine(),
ocni.getLocation().getEndColumn(), ocni.toString(), ocni.getAQlClass() ocni.getLocation().getEndColumn(), ocni.toString(), ocni.getAQlClass()

View File

@@ -1,5 +1,5 @@
--- ---
category: deprecated category: deprecated
--- ---
* Classes/predicates that had upper-case acronym XML in their name have been renamed to Xml to follow our style-guide. * Many classes/predicates/modules with upper-case acronyms in their name have been renamed to follow our style-guide.
The old name still exists as a deprecated alias. The old name still exists as a deprecated alias.

View File

@@ -132,7 +132,10 @@ class XmlFile extends XmlParent, File {
XmlElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XmlDTD getADTD() { xmlDTDs(result, _, _, _, this) } XmlDtd getADtd() { xmlDTDs(result, _, _, _, this) }
/** DEPRECATED: Alias for getADtd */
deprecated XmlDtd getADTD() { result = this.getADtd() }
} }
/** DEPRECATED: Alias for XmlFile */ /** DEPRECATED: Alias for XmlFile */
@@ -149,7 +152,7 @@ deprecated class XMLFile = XmlFile;
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XmlDTD extends XmlLocatable, @xmldtd { class XmlDtd extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -174,8 +177,8 @@ class XmlDTD extends XmlLocatable, @xmldtd {
} }
} }
/** DEPRECATED: Alias for XmlDTD */ /** DEPRECATED: Alias for XmlDtd */
deprecated class XMLDTD = XmlDTD; deprecated class XMLDTD = XmlDtd;
/** /**
* An XML element in an XML file. * An XML element in an XML file.
@@ -282,15 +285,18 @@ class XmlNamespace extends XmlLocatable, @xmlnamespace {
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
/** Gets the URI of this namespace. */ /** Gets the URI of this namespace. */
string getURI() { xmlNs(this, _, result, _) } string getUri() { xmlNs(this, _, result, _) }
/** DEPRECATED: Alias for getUri */
deprecated string getURI() { result = this.getUri() }
/** Holds if this namespace has no prefix. */ /** Holds if this namespace has no prefix. */
predicate isDefault() { this.getPrefix() = "" } predicate isDefault() { this.getPrefix() = "" }
override string toString() { override string toString() {
this.isDefault() and result = this.getURI() this.isDefault() and result = this.getUri()
or or
not this.isDefault() and result = this.getPrefix() + ":" + this.getURI() not this.isDefault() and result = this.getPrefix() + ":" + this.getUri()
} }
} }

View File

@@ -4,9 +4,9 @@
import javascript import javascript
/** Provides classes for modeling NoSQL query sinks. */ /** Provides classes for modeling NoSql query sinks. */
module NoSql { module NoSql {
/** An expression that is interpreted as a NoSQL query. */ /** An expression that is interpreted as a NoSql query. */
abstract class Query extends Expr { abstract class Query extends Expr {
/** Gets an expression that is interpreted as a code operator in this query. */ /** Gets an expression that is interpreted as a code operator in this query. */
DataFlow::Node getACodeOperator() { none() } DataFlow::Node getACodeOperator() { none() }

View File

@@ -14,15 +14,15 @@ private module ServerLess {
* Holds if the `.yml` file `ymlFile` contains a serverless configuration with `handler` and `codeURI` properties. * Holds if the `.yml` file `ymlFile` contains a serverless configuration with `handler` and `codeURI` properties.
* `codeURI` defaults to the empty string if no explicit value is set in the configuration. * `codeURI` defaults to the empty string if no explicit value is set in the configuration.
*/ */
private predicate hasServerlessHandler(File ymlFile, string handler, string codeURI) { private predicate hasServerlessHandler(File ymlFile, string handler, string codeUri) {
exists(YAMLMapping resource | ymlFile = resource.getFile() | exists(YAMLMapping resource | ymlFile = resource.getFile() |
// There exists at least "AWS::Serverless::Function" and "Aliyun::Serverless::Function" // There exists at least "AWS::Serverless::Function" and "Aliyun::Serverless::Function"
resource.lookup("Type").(YAMLScalar).getValue().regexpMatch(".*::Serverless::Function") and resource.lookup("Type").(YAMLScalar).getValue().regexpMatch(".*::Serverless::Function") and
exists(YAMLMapping properties | properties = resource.lookup("Properties") | exists(YAMLMapping properties | properties = resource.lookup("Properties") |
handler = properties.lookup("Handler").(YAMLScalar).getValue() and handler = properties.lookup("Handler").(YAMLScalar).getValue() and
if exists(properties.lookup("CodeUri")) if exists(properties.lookup("CodeUri"))
then codeURI = properties.lookup("CodeUri").(YAMLScalar).getValue() then codeUri = properties.lookup("CodeUri").(YAMLScalar).getValue()
else codeURI = "" else codeUri = ""
) )
or or
// The `serverless` library, which specifies a top-level `functions` property // The `serverless` library, which specifies a top-level `functions` property
@@ -30,7 +30,7 @@ private module ServerLess {
functions = resource.lookup("functions") and functions = resource.lookup("functions") and
not exists(resource.getParentNode()) and not exists(resource.getParentNode()) and
handler = functions.getValue(_).(YAMLMapping).lookup("handler").(YAMLScalar).getValue() and handler = functions.getValue(_).(YAMLMapping).lookup("handler").(YAMLScalar).getValue() and
codeURI = "" codeUri = ""
) )
) )
} }
@@ -58,9 +58,9 @@ private module ServerLess {
* *
* For example if `codeURI` is "function/." and `file` is "index", then the result becomes "function/index.js". * For example if `codeURI` is "function/." and `file` is "index", then the result becomes "function/index.js".
*/ */
bindingset[codeURI, file] bindingset[codeUri, file]
private string getPathFromHandlerProperties(string codeURI, string file) { private string getPathFromHandlerProperties(string codeUri, string file) {
exists(string folder | folder = removeLeadingDotSlash(removeTrailingDot(codeURI)) | exists(string folder | folder = removeLeadingDotSlash(removeTrailingDot(codeUri)) |
result = folder + file + ".js" result = folder + file + ".js"
) )
} }
@@ -69,8 +69,8 @@ private module ServerLess {
* Holds if `file` has a serverless handler function with name `func`. * Holds if `file` has a serverless handler function with name `func`.
*/ */
private predicate hasServerlessHandler(File file, string func) { private predicate hasServerlessHandler(File file, string func) {
exists(File ymlFile, string handler, string codeURI, string fileName | exists(File ymlFile, string handler, string codeUri, string fileName |
hasServerlessHandler(ymlFile, handler, codeURI) and hasServerlessHandler(ymlFile, handler, codeUri) and
// Splits a `handler` into two components. The `fileName` to the left of the dot, and the `func` to the right. // Splits a `handler` into two components. The `fileName` to the left of the dot, and the `func` to the right.
// E.g. if `handler` is "index.foo", then `fileName` is "index" and `func` is "foo". // E.g. if `handler` is "index.foo", then `fileName` is "index" and `func` is "foo".
exists(string pattern | pattern = "(.*)\\.(.*)" | exists(string pattern | pattern = "(.*)\\.(.*)" |
@@ -80,7 +80,7 @@ private module ServerLess {
| |
file.getAbsolutePath() = file.getAbsolutePath() =
ymlFile.getParentContainer().getAbsolutePath() + "/" + ymlFile.getParentContainer().getAbsolutePath() + "/" +
getPathFromHandlerProperties(codeURI, fileName) getPathFromHandlerProperties(codeUri, fileName)
) )
} }

View File

@@ -177,7 +177,7 @@ module ClientSideUrlRedirect {
) )
or or
// e.g. node.setAttribute("href", sink) // e.g. node.setAttribute("href", sink)
any(DomMethodCallExpr call).interpretsArgumentsAsURL(this.asExpr()) any(DomMethodCallExpr call).interpretsArgumentsAsUrl(this.asExpr())
} }
override predicate isXssSink() { any() } override predicate isXssSink() { any() }

View File

@@ -86,7 +86,7 @@ class DomMethodCallExpr extends MethodCallExpr {
/** /**
* Holds if `arg` is an argument that is used as an URL. * Holds if `arg` is an argument that is used as an URL.
*/ */
predicate interpretsArgumentsAsURL(Expr arg) { predicate interpretsArgumentsAsUrl(Expr arg) {
exists(int argPos, string name | exists(int argPos, string name |
arg = this.getArgument(argPos) and arg = this.getArgument(argPos) and
name = this.getMethodName() name = this.getMethodName()
@@ -103,6 +103,9 @@ class DomMethodCallExpr extends MethodCallExpr {
) )
} }
/** DEPRECATED: Alias for interpretsArgumentsAsUrl */
deprecated predicate interpretsArgumentsAsURL(Expr arg) { this.interpretsArgumentsAsUrl(arg) }
/** DEPRECATED: Alias for interpretsArgumentsAsHtml */ /** DEPRECATED: Alias for interpretsArgumentsAsHtml */
deprecated predicate interpretsArgumentsAsHTML(Expr arg) { this.interpretsArgumentsAsHtml(arg) } deprecated predicate interpretsArgumentsAsHTML(Expr arg) { this.interpretsArgumentsAsHtml(arg) }
} }

View File

@@ -23,13 +23,16 @@ deprecated class JQueryHtmlOrSelectorInjectionConfiguration = Configuration;
* A sink that is not a URL write or a JQuery selector, * A sink that is not a URL write or a JQuery selector,
* assumed to be a value that is interpreted as HTML. * assumed to be a value that is interpreted as HTML.
*/ */
class HTMLSink extends DataFlow::Node instanceof Sink { class HtmlSink extends DataFlow::Node instanceof Sink {
HTMLSink() { HtmlSink() {
not this instanceof WriteUrlSink and not this instanceof WriteUrlSink and
not this instanceof JQueryHtmlOrSelectorSink not this instanceof JQueryHtmlOrSelectorSink
} }
} }
/** DEPRECATED: Alias for HtmlSink */
deprecated class HTMLSink = HtmlSink;
/** /**
* A taint-tracking configuration for reasoning about XSS. * A taint-tracking configuration for reasoning about XSS.
* Both ordinary HTML sinks, URL sinks, and JQuery selector based sinks. * Both ordinary HTML sinks, URL sinks, and JQuery selector based sinks.
@@ -55,7 +58,7 @@ class Configuration extends TaintTracking::Configuration {
} }
override predicate isSink(DataFlow::Node sink, DataFlow::FlowLabel label) { override predicate isSink(DataFlow::Node sink, DataFlow::FlowLabel label) {
sink instanceof HTMLSink and sink instanceof HtmlSink and
label = [TaintedUrlSuffix::label(), prefixLabel(), DataFlow::FlowLabel::taint()] label = [TaintedUrlSuffix::label(), prefixLabel(), DataFlow::FlowLabel::taint()]
or or
sink instanceof JQueryHtmlOrSelectorSink and sink instanceof JQueryHtmlOrSelectorSink and

View File

@@ -1,10 +1,10 @@
/** DEPRECATED. Import `ExternalAPIUsedWithUntrustedDataQuery` instead. */ /** DEPRECATED. Import `ExternalApiUsedWithUntrustedDataQuery` instead. */
import javascript import javascript
private import ExternalAPIUsedWithUntrustedDataQuery as ExternalAPIUsedWithUntrustedDataQuery // ignore-query-import private import ExternalAPIUsedWithUntrustedDataQuery as ExternalApiUsedWithUntrustedDataQuery // ignore-query-import
/** DEPRECATED. Import `ExternalAPIUsedWithUntrustedDataQuery` instead. */ /** DEPRECATED. Import `ExternalApiUsedWithUntrustedDataQuery` instead. */
deprecated module ExternalApiUsedWithUntrustedData = ExternalAPIUsedWithUntrustedDataQuery; deprecated module ExternalApiUsedWithUntrustedData = ExternalApiUsedWithUntrustedDataQuery;
/** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */ /** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */
deprecated module ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData; deprecated module ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData;

View File

@@ -81,6 +81,7 @@ deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode;
* Name of an external API sink, boxed in a newtype for consistency with other languages. * Name of an external API sink, boxed in a newtype for consistency with other languages.
*/ */
private newtype TExternalApi = private newtype TExternalApi =
/** An external API sink with `name`. */
MkExternalApiNode(string name) { MkExternalApiNode(string name) {
exists(Sink sink | exists(Sink sink |
any(Configuration c).hasFlow(_, sink) and any(Configuration c).hasFlow(_, sink) and

View File

@@ -62,7 +62,7 @@ module Shared {
} }
} }
private import semmle.javascript.security.dataflow.IncompleteHtmlAttributeSanitizationCustomizations::IncompleteHtmlAttributeSanitization as IncompleteHTML private import semmle.javascript.security.dataflow.IncompleteHtmlAttributeSanitizationCustomizations::IncompleteHtmlAttributeSanitization as IncompleteHtml
/** /**
* A guard that checks if a string can contain quotes, which is a guard for strings that are inside a HTML attribute. * A guard that checks if a string can contain quotes, which is a guard for strings that are inside a HTML attribute.
@@ -72,7 +72,7 @@ module Shared {
this.getSubstring().mayHaveStringValue("\"") and this.getSubstring().mayHaveStringValue("\"") and
this.getBaseString() this.getBaseString()
.getALocalSource() .getALocalSource()
.flowsTo(any(IncompleteHTML::HtmlAttributeConcatenation attributeConcat)) .flowsTo(any(IncompleteHtml::HtmlAttributeConcatenation attributeConcat))
} }
override predicate sanitizes(boolean outcome, Expr e) { override predicate sanitizes(boolean outcome, Expr e) {

View File

@@ -1,5 +1,5 @@
--- ---
category: deprecated category: deprecated
--- ---
* Classes/predicates that had upper-case acronym XML in their name have been renamed to Xml to follow our style-guide. * Many classes/predicates/modules with upper-case acronyms in their name have been renamed to follow our style-guide.
The old name still exists as a deprecated alias. The old name still exists as a deprecated alias.

View File

@@ -1854,16 +1854,22 @@ private module StdlibPrivate {
deprecated API::Node cgiHTTPServer() { result = cgiHttpServer() } deprecated API::Node cgiHTTPServer() { result = cgiHttpServer() }
/** Provides models for the `CGIHTTPServer` module. */ /** Provides models for the `CGIHTTPServer` module. */
module CGIHTTPServer { module CgiHttpServer {
/** /**
* Provides models for the `CGIHTTPServer.CGIHTTPRequestHandler` class (Python 2 only). * Provides models for the `CGIHTTPServer.CGIHTTPRequestHandler` class (Python 2 only).
*/ */
module CGIHTTPRequestHandler { module CgiHttpRequestHandler {
/** Gets a reference to the `CGIHTTPServer.CGIHTTPRequestHandler` class. */ /** Gets a reference to the `CGIHTTPServer.CgiHttpRequestHandler` class. */
API::Node classRef() { result = cgiHttpServer().getMember("CGIHTTPRequestHandler") } API::Node classRef() { result = cgiHttpServer().getMember("CGIHTTPRequestHandler") }
} }
/** DEPRECATED: Alias for CgiHttpRequestHandler */
deprecated module CGIHTTPRequestHandler = CgiHttpRequestHandler;
} }
/** DEPRECATED: Alias for CgiHttpServer */
deprecated module CGIHTTPServer = CgiHttpServer;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// http (Python 3 only) // http (Python 3 only)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -1911,10 +1917,13 @@ private module StdlibPrivate {
* *
* See https://docs.python.org/3.9/library/http.server.html#http.server.CGIHTTPRequestHandler. * See https://docs.python.org/3.9/library/http.server.html#http.server.CGIHTTPRequestHandler.
*/ */
module CGIHTTPRequestHandler { module CgiHttpRequestHandler {
/** Gets a reference to the `http.server.CGIHTTPRequestHandler` class. */ /** Gets a reference to the `http.server.CGIHTTPRequestHandler` class. */
API::Node classRef() { result = server().getMember("CGIHTTPRequestHandler") } API::Node classRef() { result = server().getMember("CGIHTTPRequestHandler") }
} }
/** DEPRECATED: Alias for CgiHttpRequestHandler */
deprecated module CGIHTTPRequestHandler = CgiHttpRequestHandler;
} }
} }
@@ -1933,11 +1942,11 @@ private module StdlibPrivate {
// Python 2 // Python 2
BaseHttpServer::BaseHttpRequestHandler::classRef(), BaseHttpServer::BaseHttpRequestHandler::classRef(),
SimpleHttpServer::SimpleHttpRequestHandler::classRef(), SimpleHttpServer::SimpleHttpRequestHandler::classRef(),
CGIHTTPServer::CGIHTTPRequestHandler::classRef(), CgiHttpServer::CgiHttpRequestHandler::classRef(),
// Python 3 // Python 3
Http::Server::BaseHttpRequestHandler::classRef(), Http::Server::BaseHttpRequestHandler::classRef(),
Http::Server::SimpleHttpRequestHandler::classRef(), Http::Server::SimpleHttpRequestHandler::classRef(),
Http::Server::CGIHTTPRequestHandler::classRef() Http::Server::CgiHttpRequestHandler::classRef()
].getASubclass*() ].getASubclass*()
} }

View File

@@ -132,7 +132,10 @@ class XmlFile extends XmlParent, File {
XmlElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XmlDTD getADTD() { xmlDTDs(result, _, _, _, this) } XmlDtd getADtd() { xmlDTDs(result, _, _, _, this) }
/** DEPRECATED: Alias for getADtd */
deprecated XmlDtd getADTD() { result = this.getADtd() }
} }
/** DEPRECATED: Alias for XmlFile */ /** DEPRECATED: Alias for XmlFile */
@@ -149,7 +152,7 @@ deprecated class XMLFile = XmlFile;
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XmlDTD extends XmlLocatable, @xmldtd { class XmlDtd extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -174,8 +177,8 @@ class XmlDTD extends XmlLocatable, @xmldtd {
} }
} }
/** DEPRECATED: Alias for XmlDTD */ /** DEPRECATED: Alias for XmlDtd */
deprecated class XMLDTD = XmlDTD; deprecated class XMLDTD = XmlDtd;
/** /**
* An XML element in an XML file. * An XML element in an XML file.
@@ -282,15 +285,18 @@ class XmlNamespace extends XmlLocatable, @xmlnamespace {
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
/** Gets the URI of this namespace. */ /** Gets the URI of this namespace. */
string getURI() { xmlNs(this, _, result, _) } string getUri() { xmlNs(this, _, result, _) }
/** DEPRECATED: Alias for getUri */
deprecated string getURI() { result = this.getUri() }
/** Holds if this namespace has no prefix. */ /** Holds if this namespace has no prefix. */
predicate isDefault() { this.getPrefix() = "" } predicate isDefault() { this.getPrefix() = "" }
override string toString() { override string toString() {
this.isDefault() and result = this.getURI() this.isDefault() and result = this.getUri()
or or
not this.isDefault() and result = this.getPrefix() + ":" + this.getURI() not this.isDefault() and result = this.getPrefix() + ":" + this.getUri()
} }
} }

View File

@@ -129,7 +129,9 @@ class UntrustedExternalApiDataNode extends ExternalApiDataNode {
/** DEPRECATED: Alias for UntrustedExternalApiDataNode */ /** DEPRECATED: Alias for UntrustedExternalApiDataNode */
deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode; deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode;
/** An external API which is used with untrusted data. */
private newtype TExternalApi = private newtype TExternalApi =
/** An untrusted API method `m` where untrusted data is passed at `index`. */
TExternalApiParameter(DataFlowPrivate::DataFlowCallable callable, int index) { TExternalApiParameter(DataFlowPrivate::DataFlowCallable callable, int index) {
exists(UntrustedExternalApiDataNode n | exists(UntrustedExternalApiDataNode n |
callable = n.getCallable() and callable = n.getCallable() and

View File

@@ -19,14 +19,14 @@ private API::Node unsafe_paramiko_policy(string name) {
result = API::moduleImport("paramiko").getMember("client").getMember(name) result = API::moduleImport("paramiko").getMember("client").getMember(name)
} }
private API::Node paramikoSSHClientInstance() { private API::Node paramikoSshClientInstance() {
result = API::moduleImport("paramiko").getMember("client").getMember("SSHClient").getReturn() result = API::moduleImport("paramiko").getMember("client").getMember("SSHClient").getReturn()
} }
from DataFlow::CallCfgNode call, DataFlow::Node arg, string name from DataFlow::CallCfgNode call, DataFlow::Node arg, string name
where where
// see http://docs.paramiko.org/en/stable/api/client.html#paramiko.client.SSHClient.set_missing_host_key_policy // see http://docs.paramiko.org/en/stable/api/client.html#paramiko.client.SSHClient.set_missing_host_key_policy
call = paramikoSSHClientInstance().getMember("set_missing_host_key_policy").getACall() and call = paramikoSshClientInstance().getMember("set_missing_host_key_policy").getACall() and
arg in [call.getArg(0), call.getArgByName("policy")] and arg in [call.getArg(0), call.getArgByName("policy")] and
( (
arg = unsafe_paramiko_policy(name).getAValueReachableFromSource() or arg = unsafe_paramiko_policy(name).getAValueReachableFromSource() or

View File

@@ -7,13 +7,13 @@ private import python
private import semmle.python.ApiGraphs private import semmle.python.ApiGraphs
import TlsLibraryModel import TlsLibraryModel
class PyOpenSSLContextCreation extends ContextCreation, DataFlow::CallCfgNode { class PyOpenSslContextCreation extends ContextCreation, DataFlow::CallCfgNode {
PyOpenSSLContextCreation() { PyOpenSslContextCreation() {
this = API::moduleImport("OpenSSL").getMember("SSL").getMember("Context").getACall() this = API::moduleImport("OpenSSL").getMember("SSL").getMember("Context").getACall()
} }
override string getProtocol() { override string getProtocol() {
exists(DataFlow::Node protocolArg, PyOpenSSL pyo | exists(DataFlow::Node protocolArg, PyOpenSsl pyo |
protocolArg in [this.getArg(0), this.getArgByName("method")] protocolArg in [this.getArg(0), this.getArgByName("method")]
| |
protocolArg in [ protocolArg in [
@@ -51,12 +51,12 @@ class SetOptionsCall extends ProtocolRestriction, DataFlow::CallCfgNode {
} }
} }
class UnspecificPyOpenSSLContextCreation extends PyOpenSSLContextCreation, UnspecificContextCreation { class UnspecificPyOpenSslContextCreation extends PyOpenSslContextCreation, UnspecificContextCreation {
UnspecificPyOpenSSLContextCreation() { library instanceof PyOpenSSL } UnspecificPyOpenSslContextCreation() { library instanceof PyOpenSsl }
} }
class PyOpenSSL extends TlsLibrary { class PyOpenSsl extends TlsLibrary {
PyOpenSSL() { this = "pyOpenSSL" } PyOpenSsl() { this = "pyOpenSSL" }
override string specific_version_name(ProtocolVersion version) { result = version + "_METHOD" } override string specific_version_name(ProtocolVersion version) { result = version + "_METHOD" }
@@ -70,7 +70,7 @@ class PyOpenSSL extends TlsLibrary {
override ContextCreation default_context_creation() { none() } override ContextCreation default_context_creation() { none() }
override ContextCreation specific_context_creation() { override ContextCreation specific_context_creation() {
result instanceof PyOpenSSLContextCreation result instanceof PyOpenSslContextCreation
} }
override DataFlow::Node insecure_connection_creation(ProtocolVersion version) { none() } override DataFlow::Node insecure_connection_creation(ProtocolVersion version) { none() }
@@ -80,6 +80,6 @@ class PyOpenSSL extends TlsLibrary {
override ProtocolRestriction protocol_restriction() { result instanceof SetOptionsCall } override ProtocolRestriction protocol_restriction() { result instanceof SetOptionsCall }
override ProtocolUnrestriction protocol_unrestriction() { override ProtocolUnrestriction protocol_unrestriction() {
result instanceof UnspecificPyOpenSSLContextCreation result instanceof UnspecificPyOpenSslContextCreation
} }
} }

View File

@@ -7,8 +7,8 @@ private import python
private import semmle.python.ApiGraphs private import semmle.python.ApiGraphs
import TlsLibraryModel import TlsLibraryModel
class SSLContextCreation extends ContextCreation, DataFlow::CallCfgNode { class SslContextCreation extends ContextCreation, DataFlow::CallCfgNode {
SSLContextCreation() { this = API::moduleImport("ssl").getMember("SSLContext").getACall() } SslContextCreation() { this = API::moduleImport("ssl").getMember("SSLContext").getACall() }
override string getProtocol() { override string getProtocol() {
exists(DataFlow::Node protocolArg, Ssl ssl | exists(DataFlow::Node protocolArg, Ssl ssl |
@@ -27,8 +27,8 @@ class SSLContextCreation extends ContextCreation, DataFlow::CallCfgNode {
} }
} }
class SSLDefaultContextCreation extends ContextCreation { class SslDefaultContextCreation extends ContextCreation {
SSLDefaultContextCreation() { SslDefaultContextCreation() {
this = API::moduleImport("ssl").getMember("create_default_context").getACall() this = API::moduleImport("ssl").getMember("create_default_context").getACall()
} }
@@ -161,8 +161,8 @@ class ContextSetVersion extends ProtocolRestriction, ProtocolUnrestriction, Data
} }
} }
class UnspecificSSLContextCreation extends SSLContextCreation, UnspecificContextCreation { class UnspecificSslContextCreation extends SslContextCreation, UnspecificContextCreation {
UnspecificSSLContextCreation() { library instanceof Ssl } UnspecificSslContextCreation() { library instanceof Ssl }
override ProtocolVersion getUnrestriction() { override ProtocolVersion getUnrestriction() {
result = UnspecificContextCreation.super.getUnrestriction() and result = UnspecificContextCreation.super.getUnrestriction() and
@@ -172,7 +172,7 @@ class UnspecificSSLContextCreation extends SSLContextCreation, UnspecificContext
} }
} }
class UnspecificSSLDefaultContextCreation extends SSLDefaultContextCreation, ProtocolUnrestriction { class UnspecificSslDefaultContextCreation extends SslDefaultContextCreation, ProtocolUnrestriction {
override DataFlow::Node getContext() { result = this } override DataFlow::Node getContext() { result = this }
// see https://docs.python.org/3/library/ssl.html#ssl.create_default_context // see https://docs.python.org/3/library/ssl.html#ssl.create_default_context
@@ -195,10 +195,10 @@ class Ssl extends TlsLibrary {
override API::Node version_constants() { result = API::moduleImport("ssl") } override API::Node version_constants() { result = API::moduleImport("ssl") }
override ContextCreation default_context_creation() { override ContextCreation default_context_creation() {
result instanceof SSLDefaultContextCreation result instanceof SslDefaultContextCreation
} }
override ContextCreation specific_context_creation() { result instanceof SSLContextCreation } override ContextCreation specific_context_creation() { result instanceof SslContextCreation }
override DataFlow::CallCfgNode insecure_connection_creation(ProtocolVersion version) { override DataFlow::CallCfgNode insecure_connection_creation(ProtocolVersion version) {
result = API::moduleImport("ssl").getMember("wrap_socket").getACall() and result = API::moduleImport("ssl").getMember("wrap_socket").getACall() and
@@ -220,8 +220,8 @@ class Ssl extends TlsLibrary {
or or
result instanceof ContextSetVersion result instanceof ContextSetVersion
or or
result instanceof UnspecificSSLContextCreation result instanceof UnspecificSslContextCreation
or or
result instanceof UnspecificSSLDefaultContextCreation result instanceof UnspecificSslDefaultContextCreation
} }
} }

View File

@@ -17,8 +17,8 @@ import semmle.python.web.HttpRequest
/* Sinks */ /* Sinks */
import experimental.semmle.python.security.injection.XSLT import experimental.semmle.python.security.injection.XSLT
class XSLTInjectionConfiguration extends TaintTracking::Configuration { class XsltInjectionConfiguration extends TaintTracking::Configuration {
XSLTInjectionConfiguration() { this = "XSLT injection configuration" } XsltInjectionConfiguration() { this = "XSLT injection configuration" }
deprecated override predicate isSource(TaintTracking::Source source) { deprecated override predicate isSource(TaintTracking::Source source) {
source instanceof HttpRequestTaintSource source instanceof HttpRequestTaintSource
@@ -29,7 +29,7 @@ class XSLTInjectionConfiguration extends TaintTracking::Configuration {
} }
} }
from XSLTInjectionConfiguration config, TaintedPathSource src, TaintedPathSink sink from XsltInjectionConfiguration config, TaintedPathSource src, TaintedPathSink sink
where config.hasFlowPath(src, sink) where config.hasFlowPath(src, sink)
select sink.getSink(), src, sink, "This XSLT query depends on $@.", src.getSource(), select sink.getSink(), src, sink, "This XSLT query depends on $@.", src.getSource(),
"a user-provided value" "a user-provided value"

View File

@@ -182,7 +182,10 @@ module LdapBind {
/** /**
* Holds if the binding process use SSL. * Holds if the binding process use SSL.
*/ */
abstract predicate useSSL(); abstract predicate useSsl();
/** DEPRECATED: Alias for useSsl */
deprecated predicate useSSL() { useSsl() }
} }
} }
@@ -213,7 +216,10 @@ class LdapBind extends DataFlow::Node {
/** /**
* Holds if the binding process use SSL. * Holds if the binding process use SSL.
*/ */
predicate useSSL() { range.useSSL() } predicate useSsl() { range.useSsl() }
/** DEPRECATED: Alias for useSsl */
deprecated predicate useSSL() { useSsl() }
} }
/** DEPRECATED: Alias for LdapBind */ /** DEPRECATED: Alias for LdapBind */

View File

@@ -12,13 +12,13 @@ private import semmle.python.ApiGraphs
/** /**
* Provides models for Python's ldap-related libraries. * Provides models for Python's ldap-related libraries.
*/ */
private module LDAP { private module Ldap {
/** /**
* Provides models for the `python-ldap` PyPI package (imported as `ldap`). * Provides models for the `python-ldap` PyPI package (imported as `ldap`).
* *
* See https://www.python-ldap.org/en/python-ldap-3.3.0/index.html * See https://www.python-ldap.org/en/python-ldap-3.3.0/index.html
*/ */
private module LDAP2 { private module Ldap2 {
/** Gets a reference to the `ldap` module. */ /** Gets a reference to the `ldap` module. */
API::Node ldap() { result = API::moduleImport("ldap") } API::Node ldap() { result = API::moduleImport("ldap") }
@@ -38,8 +38,8 @@ private module LDAP {
* *
* See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#functions * See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#functions
*/ */
private class LDAP2QueryMethods extends string { private class Ldap2QueryMethods extends string {
LDAP2QueryMethods() { Ldap2QueryMethods() {
this in ["search", "search_s", "search_st", "search_ext", "search_ext_s"] this in ["search", "search_s", "search_st", "search_ext", "search_ext_s"]
} }
} }
@@ -52,7 +52,7 @@ private module LDAP {
/** Gets a reference to a `ldap` query. */ /** Gets a reference to a `ldap` query. */
private DataFlow::Node ldapQuery() { private DataFlow::Node ldapQuery() {
result = ldapOperation() and result = ldapOperation() and
result.(DataFlow::AttrRead).getAttributeName() instanceof LDAP2QueryMethods result.(DataFlow::AttrRead).getAttributeName() instanceof Ldap2QueryMethods
} }
/** /**
@@ -60,8 +60,8 @@ private module LDAP {
* *
* See `LDAP2QueryMethods` * See `LDAP2QueryMethods`
*/ */
private class LDAP2Query extends DataFlow::CallCfgNode, LdapQuery::Range { private class Ldap2Query extends DataFlow::CallCfgNode, LdapQuery::Range {
LDAP2Query() { this.getFunction() = ldapQuery() } Ldap2Query() { this.getFunction() = ldapQuery() }
override DataFlow::Node getQuery() { override DataFlow::Node getQuery() {
result in [this.getArg(0), this.getArg(2), this.getArgByName("filterstr")] result in [this.getArg(0), this.getArg(2), this.getArgByName("filterstr")]
@@ -73,8 +73,8 @@ private module LDAP {
* *
* See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#functions * See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#functions
*/ */
private class LDAP2BindMethods extends string { private class Ldap2BindMethods extends string {
LDAP2BindMethods() { Ldap2BindMethods() {
this in [ this in [
"bind", "bind_s", "simple_bind", "simple_bind_s", "sasl_interactive_bind_s", "bind", "bind_s", "simple_bind", "simple_bind_s", "sasl_interactive_bind_s",
"sasl_non_interactive_bind_s", "sasl_external_bind_s", "sasl_gssapi_bind_s" "sasl_non_interactive_bind_s", "sasl_external_bind_s", "sasl_gssapi_bind_s"
@@ -85,12 +85,12 @@ private module LDAP {
/** Gets a reference to a `ldap` bind. */ /** Gets a reference to a `ldap` bind. */
private DataFlow::Node ldapBind() { private DataFlow::Node ldapBind() {
result = ldapOperation() and result = ldapOperation() and
result.(DataFlow::AttrRead).getAttributeName() instanceof LDAP2BindMethods result.(DataFlow::AttrRead).getAttributeName() instanceof Ldap2BindMethods
} }
/**List of SSL-demanding options */ /**List of SSL-demanding options */
private class LDAPSSLOptions extends DataFlow::Node { private class LdapSslOptions extends DataFlow::Node {
LDAPSSLOptions() { LdapSslOptions() {
this = ldap().getMember("OPT_X_TLS_" + ["DEMAND", "HARD"]).getAValueReachableFromSource() this = ldap().getMember("OPT_X_TLS_" + ["DEMAND", "HARD"]).getAValueReachableFromSource()
} }
} }
@@ -100,8 +100,8 @@ private module LDAP {
* *
* See `LDAP2BindMethods` * See `LDAP2BindMethods`
*/ */
private class LDAP2Bind extends DataFlow::CallCfgNode, LdapBind::Range { private class Ldap2Bind extends DataFlow::CallCfgNode, LdapBind::Range {
LDAP2Bind() { this.getFunction() = ldapBind() } Ldap2Bind() { this.getFunction() = ldapBind() }
override DataFlow::Node getPassword() { override DataFlow::Node getPassword() {
result in [this.getArg(1), this.getArgByName("cred")] result in [this.getArg(1), this.getArgByName("cred")]
@@ -115,11 +115,11 @@ private module LDAP {
) )
} }
override predicate useSSL() { override predicate useSsl() {
// use initialize to correlate `this` and so avoid FP in several instances // use initialize to correlate `this` and so avoid FP in several instances
exists(DataFlow::CallCfgNode initialize | exists(DataFlow::CallCfgNode initialize |
// ldap.set_option(ldap.OPT_X_TLS_%s) // ldap.set_option(ldap.OPT_X_TLS_%s)
ldap().getMember("set_option").getACall().getArg(_) instanceof LDAPSSLOptions ldap().getMember("set_option").getACall().getArg(_) instanceof LdapSslOptions
or or
this.getFunction().(DataFlow::AttrRead).getObject().getALocalSource() = initialize and this.getFunction().(DataFlow::AttrRead).getObject().getALocalSource() = initialize and
initialize = ldapInitialize().getACall() and initialize = ldapInitialize().getACall() and
@@ -136,7 +136,7 @@ private module LDAP {
setOption.getFunction().(DataFlow::AttrRead).getObject().getALocalSource() = setOption.getFunction().(DataFlow::AttrRead).getObject().getALocalSource() =
initialize and initialize and
setOption.getFunction().(DataFlow::AttrRead).getAttributeName() = "set_option" and setOption.getFunction().(DataFlow::AttrRead).getAttributeName() = "set_option" and
setOption.getArg(0) instanceof LDAPSSLOptions and setOption.getArg(0) instanceof LdapSslOptions and
not DataFlow::exprNode(any(False falseExpr)) not DataFlow::exprNode(any(False falseExpr))
.(DataFlow::LocalSourceNode) .(DataFlow::LocalSourceNode)
.flowsTo(setOption.getArg(1)) .flowsTo(setOption.getArg(1))
@@ -144,6 +144,9 @@ private module LDAP {
) )
) )
} }
/** DEPRECATED: Alias for useSsl */
deprecated override predicate useSSL() { this.useSsl() }
} }
/** /**
@@ -151,8 +154,8 @@ private module LDAP {
* *
* See https://github.com/python-ldap/python-ldap/blob/7ce471e238cdd9a4dd8d17baccd1c9e05e6f894a/Lib/ldap/dn.py#L17 * See https://github.com/python-ldap/python-ldap/blob/7ce471e238cdd9a4dd8d17baccd1c9e05e6f894a/Lib/ldap/dn.py#L17
*/ */
private class LDAP2EscapeDNCall extends DataFlow::CallCfgNode, LdapEscape::Range { private class Ldap2EscapeDNCall extends DataFlow::CallCfgNode, LdapEscape::Range {
LDAP2EscapeDNCall() { this = ldap().getMember("dn").getMember("escape_dn_chars").getACall() } Ldap2EscapeDNCall() { this = ldap().getMember("dn").getMember("escape_dn_chars").getACall() }
override DataFlow::Node getAnInput() { result = this.getArg(0) } override DataFlow::Node getAnInput() { result = this.getArg(0) }
} }
@@ -162,8 +165,8 @@ private module LDAP {
* *
* See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap-filter.html#ldap.filter.escape_filter_chars * See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap-filter.html#ldap.filter.escape_filter_chars
*/ */
private class LDAP2EscapeFilterCall extends DataFlow::CallCfgNode, LdapEscape::Range { private class Ldap2EscapeFilterCall extends DataFlow::CallCfgNode, LdapEscape::Range {
LDAP2EscapeFilterCall() { Ldap2EscapeFilterCall() {
this = ldap().getMember("filter").getMember("escape_filter_chars").getACall() this = ldap().getMember("filter").getMember("escape_filter_chars").getACall()
} }
@@ -176,7 +179,7 @@ private module LDAP {
* *
* See https://pypi.org/project/ldap3/ * See https://pypi.org/project/ldap3/
*/ */
private module LDAP3 { private module Ldap3 {
/** Gets a reference to the `ldap3` module. */ /** Gets a reference to the `ldap3` module. */
API::Node ldap3() { result = API::moduleImport("ldap3") } API::Node ldap3() { result = API::moduleImport("ldap3") }
@@ -192,8 +195,8 @@ private module LDAP {
/** /**
* A class to find `ldap3` methods executing a query. * A class to find `ldap3` methods executing a query.
*/ */
private class LDAP3Query extends DataFlow::CallCfgNode, LdapQuery::Range { private class Ldap3Query extends DataFlow::CallCfgNode, LdapQuery::Range {
LDAP3Query() { Ldap3Query() {
this.getFunction().(DataFlow::AttrRead).getObject().getALocalSource() = this.getFunction().(DataFlow::AttrRead).getObject().getALocalSource() =
ldap3Connection().getACall() and ldap3Connection().getACall() and
this.getFunction().(DataFlow::AttrRead).getAttributeName() = "search" this.getFunction().(DataFlow::AttrRead).getAttributeName() = "search"
@@ -205,8 +208,8 @@ private module LDAP {
/** /**
* A class to find `ldap3` methods binding a connection. * A class to find `ldap3` methods binding a connection.
*/ */
class LDAP3Bind extends DataFlow::CallCfgNode, LdapBind::Range { class Ldap3Bind extends DataFlow::CallCfgNode, LdapBind::Range {
LDAP3Bind() { this = ldap3Connection().getACall() } Ldap3Bind() { this = ldap3Connection().getACall() }
override DataFlow::Node getPassword() { override DataFlow::Node getPassword() {
result in [this.getArg(2), this.getArgByName("password")] result in [this.getArg(2), this.getArgByName("password")]
@@ -220,7 +223,7 @@ private module LDAP {
) )
} }
override predicate useSSL() { override predicate useSsl() {
exists(DataFlow::CallCfgNode serverCall | exists(DataFlow::CallCfgNode serverCall |
serverCall = ldap3Server().getACall() and serverCall = ldap3Server().getACall() and
this.getArg(0).getALocalSource() = serverCall and this.getArg(0).getALocalSource() = serverCall and
@@ -236,6 +239,9 @@ private module LDAP {
startTLS.getObject().getALocalSource() = this startTLS.getObject().getALocalSource() = this
) )
} }
/** DEPRECATED: Alias for useSsl */
deprecated override predicate useSSL() { this.useSsl() }
} }
/** /**
@@ -243,8 +249,8 @@ private module LDAP {
* *
* See https://github.com/cannatag/ldap3/blob/4d33166f0869b929f59c6e6825a1b9505eb99967/ldap3/utils/dn.py#L390 * See https://github.com/cannatag/ldap3/blob/4d33166f0869b929f59c6e6825a1b9505eb99967/ldap3/utils/dn.py#L390
*/ */
private class LDAP3EscapeDNCall extends DataFlow::CallCfgNode, LdapEscape::Range { private class Ldap3EscapeDNCall extends DataFlow::CallCfgNode, LdapEscape::Range {
LDAP3EscapeDNCall() { this = ldap3Utils().getMember("dn").getMember("escape_rdn").getACall() } Ldap3EscapeDNCall() { this = ldap3Utils().getMember("dn").getMember("escape_rdn").getACall() }
override DataFlow::Node getAnInput() { result = this.getArg(0) } override DataFlow::Node getAnInput() { result = this.getArg(0) }
} }
@@ -254,8 +260,8 @@ private module LDAP {
* *
* See https://github.com/cannatag/ldap3/blob/4d33166f0869b929f59c6e6825a1b9505eb99967/ldap3/utils/conv.py#L91 * See https://github.com/cannatag/ldap3/blob/4d33166f0869b929f59c6e6825a1b9505eb99967/ldap3/utils/conv.py#L91
*/ */
private class LDAP3EscapeFilterCall extends DataFlow::CallCfgNode, LdapEscape::Range { private class Ldap3EscapeFilterCall extends DataFlow::CallCfgNode, LdapEscape::Range {
LDAP3EscapeFilterCall() { Ldap3EscapeFilterCall() {
this = ldap3Utils().getMember("conv").getMember("escape_filter_chars").getACall() this = ldap3Utils().getMember("conv").getMember("escape_filter_chars").getACall()
} }

View File

@@ -122,7 +122,7 @@ class LdapInsecureAuthConfig extends TaintTracking::Configuration {
} }
override predicate isSink(DataFlow::Node sink) { override predicate isSink(DataFlow::Node sink) {
exists(LdapBind ldapBind | not ldapBind.useSSL() and sink = ldapBind.getHost()) exists(LdapBind ldapBind | not ldapBind.useSsl() and sink = ldapBind.getHost())
} }
} }

View File

@@ -11,12 +11,15 @@ import semmle.python.dataflow.TaintTracking
import semmle.python.web.HttpRequest import semmle.python.web.HttpRequest
/** Models XSLT Injection related classes and functions */ /** Models XSLT Injection related classes and functions */
module XSLTInjection { module XsltInjection {
/** Returns a class value which refers to `lxml.etree` */ /** Returns a class value which refers to `lxml.etree` */
Value etree() { result = Value::named("lxml.etree") } Value etree() { result = Value::named("lxml.etree") }
/** A generic taint sink that is vulnerable to XSLT injection. */ /** A generic taint sink that is vulnerable to XSLT injection. */
abstract class XSLTInjectionSink extends TaintSink { } abstract class XsltInjectionSink extends TaintSink { }
/** DEPRECATED: Alias for XsltInjectionSink */
deprecated class XSLTInjectionSink = XsltInjectionSink;
/** /**
* A kind of "taint", representing an untrusted XML string * A kind of "taint", representing an untrusted XML string
@@ -73,10 +76,10 @@ module XSLTInjection {
* root = etree.XML("<xmlContent>") * root = etree.XML("<xmlContent>")
* find_text = etree.XSLT("`sink`") * find_text = etree.XSLT("`sink`")
*/ */
private class EtreeXSLTArgument extends XSLTInjectionSink { private class EtreeXsltArgument extends XsltInjectionSink {
override string toString() { result = "lxml.etree.XSLT" } override string toString() { result = "lxml.etree.XSLT" }
EtreeXSLTArgument() { EtreeXsltArgument() {
exists(CallNode call | call.getFunction().(AttrNode).getObject("XSLT").pointsTo(etree()) | exists(CallNode call | call.getFunction().(AttrNode).getObject("XSLT").pointsTo(etree()) |
call.getArg(0) = this call.getArg(0) = this
) )
@@ -94,10 +97,10 @@ module XSLTInjection {
* tree = etree.parse(f) * tree = etree.parse(f)
* result_tree = tree.xslt(`sink`) * result_tree = tree.xslt(`sink`)
*/ */
private class ParseXSLTArgument extends XSLTInjectionSink { private class ParseXsltArgument extends XsltInjectionSink {
override string toString() { result = "lxml.etree.parse.xslt" } override string toString() { result = "lxml.etree.parse.xslt" }
ParseXSLTArgument() { ParseXsltArgument() {
exists( exists(
CallNode parseCall, CallNode xsltCall, ControlFlowNode obj, Variable var, AssignStmt assign CallNode parseCall, CallNode xsltCall, ControlFlowNode obj, Variable var, AssignStmt assign
| |
@@ -113,3 +116,6 @@ module XSLTInjection {
override predicate sinks(TaintKind kind) { kind instanceof ExternalXmlKind } override predicate sinks(TaintKind kind) { kind instanceof ExternalXmlKind }
} }
} }
/** DEPRECATED: Alias for XsltInjection */
deprecated module XSLTInjection = XsltInjection;

View File

@@ -1,6 +1,6 @@
import python import python
import experimental.semmle.python.security.injection.XSLT import experimental.semmle.python.security.injection.XSLT
from XSLTInjection::XSLTInjectionSink sink, TaintKind kind from XsltInjection::XsltInjectionSink sink, TaintKind kind
where sink.sinks(kind) where sink.sinks(kind)
select sink, kind select sink, kind

View File

@@ -714,7 +714,7 @@ module PersistentWriteAccess {
* Extend this class to refine existing API models. If you want to model new APIs, * Extend this class to refine existing API models. If you want to model new APIs,
* extend `CSRFProtectionSetting::Range` instead. * extend `CSRFProtectionSetting::Range` instead.
*/ */
class CSRFProtectionSetting extends DataFlow::Node instanceof CSRFProtectionSetting::Range { class CsrfProtectionSetting extends DataFlow::Node instanceof CsrfProtectionSetting::Range {
/** /**
* Gets the boolean value corresponding to if CSRF protection is enabled * Gets the boolean value corresponding to if CSRF protection is enabled
* (`true`) or disabled (`false`) by this node. * (`true`) or disabled (`false`) by this node.
@@ -722,8 +722,11 @@ class CSRFProtectionSetting extends DataFlow::Node instanceof CSRFProtectionSett
boolean getVerificationSetting() { result = super.getVerificationSetting() } boolean getVerificationSetting() { result = super.getVerificationSetting() }
} }
/** DEPRECATED: Alias for CsrfProtectionSetting */
deprecated class CSRFProtectionSetting = CsrfProtectionSetting;
/** Provides a class for modeling new CSRF protection setting APIs. */ /** Provides a class for modeling new CSRF protection setting APIs. */
module CSRFProtectionSetting { module CsrfProtectionSetting {
/** /**
* A data-flow node that may set or unset Cross-site request forgery protection. * A data-flow node that may set or unset Cross-site request forgery protection.
* *
@@ -739,6 +742,9 @@ module CSRFProtectionSetting {
} }
} }
/** DEPRECATED: Alias for CsrfProtectionSetting */
deprecated module CSRFProtectionSetting = CsrfProtectionSetting;
/** Provides classes for modeling path-related APIs. */ /** Provides classes for modeling path-related APIs. */
module Path { module Path {
/** /**

Some files were not shown because too many files have changed in this diff Show More