-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Java: Add models for spring WebSocketHandler #20999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
41b94e7
a594ca9
1d61da5
d98e660
d0cd4ee
94fcee5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Additional remote flow sources from the `org.springframework.web.socket` package have been modeled. |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||||
| extensions: | ||||||||
| - addsTo: | ||||||||
| pack: codeql/java-all | ||||||||
| extensible: sourceModel | ||||||||
| data: | ||||||||
| - ["org.springframework.web.socket", "WebSocketHandler", True, "afterConnectionClosed", "", "", "Parameter[0]", "remote", "manual"] | ||||||||
| - ["org.springframework.web.socket", "WebSocketHandler", True, "afterConnectionEstablished", "", "", "Parameter[0]", "remote", "manual"] | ||||||||
| - ["org.springframework.web.socket", "WebSocketHandler", True, "handleMessage", "", "", "Parameter[0]", "remote", "manual"] | ||||||||
| - ["org.springframework.web.socket", "WebSocketHandler", True, "handleMessage", "", "", "Parameter[1]", "remote", "manual"] | ||||||||
| - ["org.springframework.web.socket", "WebSocketHandler", True, "handleTransportError", "", "", "Parameter[0]", "remote", "manual"] | ||||||||
| - ["org.springframework.web.socket.handler", "AbstractWebSocketHandler", True, "handleBinaryMessage", "", "", "Parameter[0]", "remote", "manual"] | ||||||||
| - ["org.springframework.web.socket.handler", "AbstractWebSocketHandler", True, "handleBinaryMessage", "", "", "Parameter[1]", "remote", "manual"] | ||||||||
| - ["org.springframework.web.socket.handler", "AbstractWebSocketHandler", True, "handleTextMessage", "", "", "Parameter[0]", "remote", "manual"] | ||||||||
| - ["org.springframework.web.socket.handler", "AbstractWebSocketHandler", True, "handleTextMessage", "", "", "Parameter[1]", "remote", "manual"] | ||||||||
| - addsTo: | ||||||||
| pack: codeql/java-all | ||||||||
| extensible: summaryModel | ||||||||
| data: | ||||||||
| - ["org.springframework.web.socket", "TextMessage", True, "asBytes", "", "", "Argument[this]", "ReturnValue", "taint", "manual"] | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| - ["org.springframework.web.socket", "WebSocketMessage", True, "getPayload", "", "", "Argument[this]", "ReturnValue", "taint", "manual"] | ||||||||
| - ["org.springframework.web.socket", "WebSocketSession", True, "getAcceptedProtocol", "", "", "Argument[this]", "ReturnValue", "taint", "manual"] | ||||||||
| - ["org.springframework.web.socket", "WebSocketSession", True, "getHandshakeHeaders", "", "", "Argument[this]", "ReturnValue", "taint", "manual"] | ||||||||
| - ["org.springframework.web.socket", "WebSocketSession", True, "getPrincipal", "", "", "Argument[this]", "ReturnValue", "taint", "manual"] | ||||||||
| - ["org.springframework.web.socket", "WebSocketSession", True, "getUri", "", "", "Argument[this]", "ReturnValue", "taint", "manual"] | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
|
|
||
| import org.springframework.web.socket.handler.TextWebSocketHandler; | ||
| import org.springframework.web.socket.WebSocketSession; | ||
| import org.springframework.web.socket.WebSocketMessage; | ||
| import org.springframework.web.socket.TextMessage; | ||
| import org.springframework.web.socket.BinaryMessage; | ||
| import org.springframework.web.socket.CloseStatus; | ||
|
|
||
|
|
||
| public class Test { | ||
| void sink(Object o) {} | ||
|
|
||
| public class A extends TextWebSocketHandler { | ||
| @Override | ||
| public void handleMessage(WebSocketSession s, WebSocketMessage<?> m) { | ||
| sink(s); // $hasTaintFlow | ||
| sink(s.getAcceptedProtocol()); // $hasTaintFlow | ||
| sink(s.getHandshakeHeaders()); // $hasTaintFlow | ||
| sink(s.getPrincipal()); // $hasTaintFlow | ||
| sink(s.getUri()); // $hasTaintFlow | ||
|
|
||
| sink(m); // $hasTaintFlow | ||
| sink(m.getPayload()); // $hasTaintFlow | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| protected void handleTextMessage(WebSocketSession s, TextMessage m) { | ||
| sink(s); // $hasTaintFlow | ||
| sink(m); // $hasTaintFlow | ||
| sink(m.asBytes()); // $hasTaintFlow | ||
| } | ||
|
|
||
| @Override | ||
| protected void handleBinaryMessage(WebSocketSession s, BinaryMessage m) { | ||
| sink(s); // $hasTaintFlow | ||
| sink(m); // $hasTaintFlow | ||
| } | ||
|
|
||
| @Override | ||
| public void afterConnectionEstablished(WebSocketSession s) { | ||
| sink(s); // $hasTaintFlow | ||
| } | ||
|
|
||
| @Override | ||
| public void afterConnectionClosed(WebSocketSession s, CloseStatus c) { | ||
| sink(s); // $hasTaintFlow | ||
| } | ||
|
|
||
| @Override | ||
| public void handleTransportError(WebSocketSession s, Throwable exc) { | ||
| sink(s); // $hasTaintFlow | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| //semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/springframework-5.8.x:${testdir}/../../../../stubs/javax-servlet-2.5:${testdir}/../../../../stubs/apache-commons-logging-1.2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import java | ||
| import semmle.code.java.dataflow.DataFlow | ||
Check warningCode scanning / CodeQL Redundant import Warning test
Redundant import, the module is already imported inside
semmle.code.java.dataflow.FlowSources Error loading related location Loading Redundant import, the module is already imported inside utils.test.InlineFlowTest Error loading related location Loading |
||
| import semmle.code.java.dataflow.FlowSources | ||
| import utils.test.InlineFlowTest | ||
|
|
||
| module Config implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node node) { | ||
| DefaultFlowConfig::isSource(node) | ||
| or | ||
| node instanceof ActiveThreatModelSource | ||
| } | ||
|
|
||
| predicate isSink = DefaultFlowConfig::isSink/1; | ||
| } | ||
|
|
||
| import FlowTest<DefaultFlowConfig, Config> | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter[0,1]orParameter[0..1].handlePongMessage, as it can have a string payload. It's generally just compared to what was sent in a ping message, but I suppose it might be logged or something.