Skip to content

Commit 894b3f2

Browse files
committed
Add or change qldocs
1 parent 8db5c4f commit 894b3f2

File tree

1 file changed

+9
-4
lines changed
  • java/ql/src/semmle/code/java/security

1 file changed

+9
-4
lines changed

java/ql/src/semmle/code/java/security/XSS.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Provides classes to reason about Cross-site scripting (XSS) vulnerabilities. */
2+
13
import java
24
import semmle.code.java.frameworks.Servlets
35
import semmle.code.java.frameworks.android.WebView
@@ -6,12 +8,10 @@ import semmle.code.java.frameworks.spring.SpringHttp
68
import semmle.code.java.dataflow.DataFlow
79
import semmle.code.java.dataflow.TaintTracking2
810

9-
/*
10-
* Definitions for XSS sinks
11-
*/
12-
11+
/** A sink that represent a method that outputs data without applying contextual output encoding. */
1312
abstract class XssSink extends DataFlow::Node { }
1413

14+
/** A sanitizer that neutralizes dangerous characters that can be used to perform a XSS attack. */
1515
abstract class XssSanitizer extends DataFlow::Node { }
1616

1717
/**
@@ -28,6 +28,7 @@ abstract class XssAdditionalTaintStep extends TaintTracking2::Unit {
2828
abstract predicate step(DataFlow::Node node1, DataFlow::Node node2);
2929
}
3030

31+
/** A default sink representing methods susceptible to XSS attacks. */
3132
private class DefaultXssSink extends XssSink {
3233
DefaultXssSink() {
3334
exists(HttpServletResponseSendErrorMethod m, MethodAccess ma |
@@ -96,12 +97,14 @@ private class DefaultXssSink extends XssSink {
9697
}
9798
}
9899

100+
/** A default sanitizer that considers numeric and boolean typed data safe for writing to output. */
99101
private class DefaultXSSSanitizer extends XssSanitizer {
100102
DefaultXSSSanitizer() {
101103
this.getType() instanceof NumericType or this.getType() instanceof BooleanType
102104
}
103105
}
104106

107+
/** A configuration that tracks data from a servlet writer to an output method. */
105108
private class ServletWriterSourceToWritingMethodFlowConfig extends TaintTracking2::Configuration {
106109
ServletWriterSourceToWritingMethodFlowConfig() {
107110
this = "XSS::ServletWriterSourceToWritingMethodFlowConfig"
@@ -116,6 +119,7 @@ private class ServletWriterSourceToWritingMethodFlowConfig extends TaintTracking
116119
}
117120
}
118121

122+
/** A class representing methods that can be used to output data. */
119123
private class WritingMethod extends Method {
120124
WritingMethod() {
121125
getDeclaringType().getASupertype*().hasQualifiedName("java.io", _) and
@@ -127,6 +131,7 @@ private class WritingMethod extends Method {
127131
}
128132
}
129133

134+
/** A class representing methods that provides access to an output stream or writer. */
130135
class ServletWriterSource extends MethodAccess {
131136
ServletWriterSource() {
132137
this.getMethod() instanceof ServletResponseGetWriterMethod

0 commit comments

Comments
 (0)