-
Notifications
You must be signed in to change notification settings - Fork 1
Remove FPs of js/ui5-log-injection-to-http
#190
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?
Conversation
1. Minor comment formatting 2. Unify the TypeTrackers into one (hasDependency) 3. Some more modeling
This allows reuse of UI5LogInjection in UI5LogsToHttp.
and correctly skip the FP case
...but why has it been working even before this fix?
"use strict"; | ||
return BaseObject.extend("codeql-sap-js.log.CustomLogListener", { | ||
constructor: function () { | ||
let message = Log.getLogEntries()[0].message; |
Check warning
Code scanning / CodeQL
Access to user-controlled UI5 Logs Medium test
user-provided data
const http = new XMLHttpRequest(); | ||
const url = "https://some.remote.server/location"; | ||
http.open("POST", url); | ||
http.send(message); // js/ui5-log-injection-to-http |
Check warning
Code scanning / CodeQL
UI5 Log injection in outbound network request Medium test
user-provided
Log.debug(input); // | ||
/* 2. Create a JS object that implements Log.Listener on-the-fly. */ | ||
Log.addLogListener({ | ||
onLogEntry: function (oLogEntry) { |
Check warning
Code scanning / CodeQL
Access to user-controlled UI5 Logs Medium test
user-provided data
const http = new XMLHttpRequest(); | ||
const url = "https://some.remote.server/location"; | ||
http.open("POST", url); | ||
http.send(oLogEntry.message); // js/ui5-log-injection-to-http |
Check warning
Code scanning / CodeQL
UI5 Log injection in outbound network request Medium test
user-provided
constructor: function () { | ||
Log.addLogListener(this); | ||
}, | ||
onLogEntry: function (oLogEntry) { |
Check warning
Code scanning / CodeQL
Access to user-controlled UI5 Logs Medium test
user-provided data
const http = new XMLHttpRequest(); | ||
const url = "https://some.remote.server/location"; | ||
http.open("POST", url); | ||
http.send(oLogEntry.message); // js/ui5-log-injection-to-http |
Check warning
Code scanning / CodeQL
UI5 Log injection in outbound network request Medium test
user-provided
This step involves `DataFlow::FlowLabel`s that is subjective to the query that is using this step. Therefore, remove it from the shared flow step, and put it only in the query or query library which define the labels to be propagated through this step.
What this PR contributes
Eliminate FPs
The query
js/ui5-log-injection-to-http
yielded false positives on code that does not depend on UI5, because the query did not check if the data being sent via HTTP is indeed derived from a UI5 log entry (by means ofonLogEntry
orgetLogEntries
). Therefore, enforce it by using flow labels.Tidy up code
Factor out various type trackers into one (
hasDependency/1
)There were
sapControl/0
,sapController/0
,sapRenderer/0
, andsapComponent/0
that gives rise to classes such asCustomControl
,CustomController
, and so on. However, all of them differed in only the dependency paths they referred to, and keeping them more or less pollluted the code. Therefore, add ahasDependency/1
parameterized with the dependency path.Split up
log-entry-flows-to-sinks
The unit test case
log-entry-flows-to-sinks
combined several kinds of sinks all in one test case (hence the name). Split it up into several smaller ones:log-entry-flows-to-http-getLogEntries
: getLogEntries is used to fetch a log entry to be sent in an XmlHttpRequest.log-entry-flows-to-http-log-listener-js-object
: a log listener as a plain JS object (that implements it implicitly) has a methodonLogEntries
which pulls a log entry on a log event and sends it in an XmlHttpRequest.log-entry-flows-to-http-log-listener-sap-module
: Same as the example right above, instead it's a UI5 module that explicitly implements it.log-entry-flows-to-http-log-listener-sap-module-imported
: See Future Work below.Miscellaneous
Fix access path of
SapLogEntries
in the library modelOne of the rows contributing to the type
SapLogEntries
had this row:["SapLogEntries", "SapLogger", "Member[addLogListener].Parameter[0].Member[onLogEntry].Argument[0]"]
It confused
Parameter
withArgument
and vice versa, so put them in the right places.Also, as per the UI5 documentation on sap/base/Log.Logger, all of the various logging functions do not return another Logger (they are of void type), so delete this row:
["SapLogger", "SapLogger", "Member[debug,error,fatal,info,setLevel,trace,warning,getLogger].ReturnValue"]
Separate out
UI5LogInjectionQuery
into a library moduleThis is to reuse the configuration in
UI5LogsToHttp
.Future work
log-entry-flows-to-http-log-listener-sap-module-imported
). This is currently partially blocked as of now due to limitations inAmdModuleDefinition::Range
(see github/codeql, PR #19359); this prevents us from modelingsap.ui.require
, an another way of requiring a UI5 module.