mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
99 lines
3.0 KiB
Plaintext
99 lines
3.0 KiB
Plaintext
/**
|
|
* Apache Camel messaging framework.
|
|
*/
|
|
|
|
import java
|
|
import semmle.code.java.frameworks.spring.SpringCamel
|
|
import semmle.code.java.frameworks.camel.CamelJavaDSL
|
|
import semmle.code.java.frameworks.camel.CamelJavaAnnotations
|
|
|
|
/**
|
|
* A string describing a URI specified in an Apache Camel "to" declaration.
|
|
*/
|
|
class CamelToUri extends string {
|
|
CamelToUri() {
|
|
exists(SpringCamelXmlToElement toXmlElement | this = toXmlElement.getUri()) or
|
|
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
|
|
* SpringBean.
|
|
*/
|
|
class CamelToBeanUri extends CamelToUri {
|
|
CamelToBeanUri() {
|
|
// A `<to>` element references a bean if the URI starts with "bean:", or there is no scheme.
|
|
matches("bean:%") or
|
|
not exists(indexOf(":"))
|
|
}
|
|
|
|
/**
|
|
* Gets the identifier of the Spring Bean that is the target of this URI.
|
|
*
|
|
* The URI is of the form: `bean:BeanName?method", where the "bean:" scheme and "?methodname"
|
|
* parameter parts are optional.
|
|
*/
|
|
string getBeanIdentifier() {
|
|
if not exists(indexOf(":"))
|
|
then result = this
|
|
else
|
|
exists(int start | start = indexOf(":", 0, 0) + 1 |
|
|
if not exists(indexOf("?"))
|
|
then result = suffix(start)
|
|
else result = substring(start, indexOf("?", 0, 0))
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Gets the bean referenced by this URI.
|
|
*/
|
|
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.
|
|
*/
|
|
class CamelTargetClass extends Class {
|
|
CamelTargetClass() {
|
|
exists(SpringCamelXmlBeanRef camelXmlBeanRef |
|
|
// A target may be defined by referencing an existing Spring Bean.
|
|
this = camelXmlBeanRef.getRefBean().getClass()
|
|
or
|
|
// A target may be defined by referencing a class, which Apache Camel will create into a bean.
|
|
this = camelXmlBeanRef.getBeanType()
|
|
)
|
|
or
|
|
exists(CamelToBeanUri toBeanUri | this = toBeanUri.getRefBean().getClass())
|
|
or
|
|
exists(SpringCamelXmlMethodElement xmlMethod |
|
|
this = xmlMethod.getRefBean().getClass() or
|
|
this = xmlMethod.getBeanType()
|
|
)
|
|
or
|
|
exists(CamelJavaDslMethodDecl methodDecl | this = methodDecl.getABean())
|
|
or
|
|
// Any beans referred to in Java DSL bean or beanRef elements are considered as possible
|
|
// targets. Whether the route builder is ever constructed or called is not considered.
|
|
exists(CamelJavaDslBeanDecl beanDecl | this = beanDecl.getABeanClass())
|
|
or
|
|
exists(CamelJavaDslBeanRefDecl beanRefDecl | this = beanRefDecl.getABeanClass())
|
|
}
|
|
|
|
/**
|
|
* Gets a method that may be called by Apache Camel.
|
|
*
|
|
* Any public method inherited by this class is assumed to be callable by Apache Camel.
|
|
*/
|
|
Method getACamelCalledMethod() {
|
|
this.inherits(result) and
|
|
result.isPublic()
|
|
}
|
|
}
|