Skip to content

Commit ed8e5d2

Browse files
authored
ci: Set up CodeQL analysis w/ fixes (#1711)
* ci: Set up CodeQL analysis * spec: disable allowBackup in testing * ci: do not check cordova.js - convered in cordova-js repo * chore: add missing @OverRide annotation
1 parent 7fa4a65 commit ed8e5d2

18 files changed

+88
-9
lines changed

.github/workflows/ci.yml

+20-6
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@ jobs:
3131
os: [ubuntu-latest, windows-latest, macos-latest]
3232

3333
steps:
34-
- uses: actions/checkout@v3
35-
36-
- name: Use Node.js ${{ matrix.node-version }}
37-
uses: actions/setup-node@v3
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-node@v4
3836
with:
3937
node-version: ${{ matrix.node-version }}
4038

41-
- name: set up JDK 11
42-
uses: actions/setup-java@v3
39+
- uses: actions/setup-java@v4
4340
with:
4441
distribution: 'temurin'
4542
java-version: '11'
@@ -50,13 +47,30 @@ jobs:
5047
npm --version
5148
gradle --version
5249
50+
# "bin/templates/platform_www/cordova.js" is ignored because it is a generated file.
51+
# It contains mixed content from the npm package "cordova-js" and "./cordova-js-src".
52+
# The report might not be resolvable because of the external package.
53+
# If the report is related to this repository, it would be detected when scanning "./cordova-js-src".
54+
- uses: github/codeql-action/init@v3
55+
with:
56+
languages: javascript, java-kotlin
57+
queries: security-and-quality
58+
config: |
59+
paths-ignore:
60+
- coverage
61+
- node_modules
62+
- templates/project/assets/www/cordova.js
63+
- test/androidx/app/src/main/assets/www/cordova.js
64+
5365
- name: npm install and test
5466
run: |
5567
npm i
5668
npm t
5769
env:
5870
CI: true
5971

72+
- uses: github/codeql-action/analyze@v3
73+
6074
- uses: codecov/codecov-action@v4
6175
if: success()
6276
with:

framework/src/org/apache/cordova/CordovaActivity.java

+5
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ public void onReceivedError(final int errorCode, final String description, final
391391
if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
392392
// Load URL on UI thread
393393
me.runOnUiThread(new Runnable() {
394+
@Override
394395
public void run() {
395396
me.appView.showWebPage(errorUrl, false, true, null);
396397
}
@@ -400,6 +401,7 @@ public void run() {
400401
else {
401402
final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
402403
me.runOnUiThread(new Runnable() {
404+
@Override
403405
public void run() {
404406
if (exit) {
405407
me.appView.getView().setVisibility(View.GONE);
@@ -416,6 +418,7 @@ public void run() {
416418
public void displayError(final String title, final String message, final String button, final boolean exit) {
417419
final CordovaActivity me = this;
418420
me.runOnUiThread(new Runnable() {
421+
@Override
419422
public void run() {
420423
try {
421424
AlertDialog.Builder dlg = new AlertDialog.Builder(me);
@@ -424,6 +427,7 @@ public void run() {
424427
dlg.setCancelable(false);
425428
dlg.setPositiveButton(button,
426429
new AlertDialog.OnClickListener() {
430+
@Override
427431
public void onClick(DialogInterface dialog, int which) {
428432
dialog.dismiss();
429433
if (exit) {
@@ -488,6 +492,7 @@ public Object onMessage(String id, Object data) {
488492
return null;
489493
}
490494

495+
@Override
491496
protected void onSaveInstanceState(Bundle outState) {
492497
cordovaInterface.onSaveInstanceState(outState);
493498
super.onSaveInstanceState(outState);

framework/src/org/apache/cordova/CordovaClientCertRequest.java

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public CordovaClientCertRequest(ClientCertRequest request) {
4141
* Cancel this request
4242
*/
4343
@SuppressLint("NewApi")
44+
@Override
4445
public void cancel()
4546
{
4647
request.cancel();
@@ -50,6 +51,7 @@ public void cancel()
5051
* Returns the host name of the server requesting the certificate.
5152
*/
5253
@SuppressLint("NewApi")
54+
@Override
5355
public String getHost()
5456
{
5557
return request.getHost();
@@ -59,6 +61,7 @@ public String getHost()
5961
* Returns the acceptable types of asymmetric keys (can be null).
6062
*/
6163
@SuppressLint("NewApi")
64+
@Override
6265
public String[] getKeyTypes()
6366
{
6467
return request.getKeyTypes();
@@ -68,6 +71,7 @@ public String[] getKeyTypes()
6871
* Returns the port number of the server requesting the certificate.
6972
*/
7073
@SuppressLint("NewApi")
74+
@Override
7175
public int getPort()
7276
{
7377
return request.getPort();
@@ -77,6 +81,7 @@ public int getPort()
7781
* Returns the acceptable certificate issuers for the certificate matching the private key (can be null).
7882
*/
7983
@SuppressLint("NewApi")
84+
@Override
8085
public Principal[] getPrincipals()
8186
{
8287
return request.getPrincipals();
@@ -86,6 +91,7 @@ public Principal[] getPrincipals()
8691
* Ignore the request for now. Do not remember user's choice.
8792
*/
8893
@SuppressLint("NewApi")
94+
@Override
8995
public void ignore()
9096
{
9197
request.ignore();
@@ -98,6 +104,7 @@ public void ignore()
98104
* @param chain The certificate chain
99105
*/
100106
@SuppressLint("NewApi")
107+
@Override
101108
public void proceed(PrivateKey privateKey, X509Certificate[] chain)
102109
{
103110
request.proceed(privateKey, chain);

framework/src/org/apache/cordova/CordovaDialogsHelper.java

+9
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,21 @@ public void showAlert(String message, final Result result) {
4343
dlg.setCancelable(true);
4444
dlg.setPositiveButton(android.R.string.ok,
4545
new AlertDialog.OnClickListener() {
46+
@Override
4647
public void onClick(DialogInterface dialog, int which) {
4748
result.gotResult(true, null);
4849
}
4950
});
5051
dlg.setOnCancelListener(
5152
new DialogInterface.OnCancelListener() {
53+
@Override
5254
public void onCancel(DialogInterface dialog) {
5355
result.gotResult(false, null);
5456
}
5557
});
5658
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
5759
//DO NOTHING
60+
@Override
5861
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
5962
if (keyCode == KeyEvent.KEYCODE_BACK)
6063
{
@@ -75,24 +78,28 @@ public void showConfirm(String message, final Result result) {
7578
dlg.setCancelable(true);
7679
dlg.setPositiveButton(android.R.string.ok,
7780
new DialogInterface.OnClickListener() {
81+
@Override
7882
public void onClick(DialogInterface dialog, int which) {
7983
result.gotResult(true, null);
8084
}
8185
});
8286
dlg.setNegativeButton(android.R.string.cancel,
8387
new DialogInterface.OnClickListener() {
88+
@Override
8489
public void onClick(DialogInterface dialog, int which) {
8590
result.gotResult(false, null);
8691
}
8792
});
8893
dlg.setOnCancelListener(
8994
new DialogInterface.OnCancelListener() {
95+
@Override
9096
public void onCancel(DialogInterface dialog) {
9197
result.gotResult(false, null);
9298
}
9399
});
94100
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
95101
//DO NOTHING
102+
@Override
96103
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
97104
if (keyCode == KeyEvent.KEYCODE_BACK)
98105
{
@@ -126,13 +133,15 @@ public void showPrompt(String message, String defaultValue, final Result result)
126133
dlg.setCancelable(false);
127134
dlg.setPositiveButton(android.R.string.ok,
128135
new DialogInterface.OnClickListener() {
136+
@Override
129137
public void onClick(DialogInterface dialog, int which) {
130138
String userText = input.getText().toString();
131139
result.gotResult(true, userText);
132140
}
133141
});
134142
dlg.setNegativeButton(android.R.string.cancel,
135143
new DialogInterface.OnClickListener() {
144+
@Override
136145
public void onClick(DialogInterface dialog, int which) {
137146
result.gotResult(false, null);
138147
}

framework/src/org/apache/cordova/CordovaHttpAuthHandler.java

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public CordovaHttpAuthHandler(HttpAuthHandler handler) {
3535
/**
3636
* Instructs the WebView to cancel the authentication request.
3737
*/
38+
@Override
3839
public void cancel () {
3940
this.handler.cancel();
4041
}
@@ -45,6 +46,7 @@ public void cancel () {
4546
* @param username
4647
* @param password
4748
*/
49+
@Override
4850
public void proceed (String username, String password) {
4951
this.handler.proceed(username, password);
5052
}

framework/src/org/apache/cordova/CordovaInterfaceImpl.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,21 @@ public void onRequestPermissionResult(int requestCode, String[] permissions,
223223
}
224224
}
225225

226+
@Override
226227
public void requestPermission(CordovaPlugin plugin, int requestCode, String permission) {
227228
String[] permissions = new String [1];
228229
permissions[0] = permission;
229230
requestPermissions(plugin, requestCode, permissions);
230231
}
231232

232-
@SuppressLint("NewApi")
233+
@SuppressLint("NewApi")
234+
@Override
233235
public void requestPermissions(CordovaPlugin plugin, int requestCode, String [] permissions) {
234236
int mappedRequestCode = permissionResultCallbacks.registerCallback(plugin, requestCode);
235237
getActivity().requestPermissions(permissions, mappedRequestCode);
236238
}
237239

240+
@Override
238241
public boolean hasPermission(String permission)
239242
{
240243
return PackageManager.PERMISSION_GRANTED == activity.checkSelfPermission(permission);

framework/src/org/apache/cordova/CordovaWebViewImpl.java

+5
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public void loadUrlIntoView(final String url, boolean recreatePlugins) {
149149

150150
// Timeout error method
151151
final Runnable loadError = new Runnable() {
152+
@Override
152153
public void run() {
153154
stopLoading();
154155
LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!");
@@ -168,6 +169,7 @@ public void run() {
168169

169170
// Timeout timer method
170171
final Runnable timeoutCheck = new Runnable() {
172+
@Override
171173
public void run() {
172174
try {
173175
synchronized (this) {
@@ -189,6 +191,7 @@ public void run() {
189191
if (cordova.getActivity() != null) {
190192
final boolean _recreatePlugins = recreatePlugins;
191193
cordova.getActivity().runOnUiThread(new Runnable() {
194+
@Override
192195
public void run() {
193196
if (loadUrlTimeoutValue > 0) {
194197
cordova.getThreadPool().execute(timeoutCheck);
@@ -579,11 +582,13 @@ public void onPageFinishedLoading(String url) {
579582
// Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
580583
if (engine.getView().getVisibility() != View.VISIBLE) {
581584
Thread t = new Thread(new Runnable() {
585+
@Override
582586
public void run() {
583587
try {
584588
Thread.sleep(2000);
585589
if (cordova.getActivity() != null) {
586590
cordova.getActivity().runOnUiThread(new Runnable() {
591+
@Override
587592
public void run() {
588593
pluginManager.postMessage("spinner", "stop");
589594
}

framework/src/org/apache/cordova/CoreAndroid.java

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public void pluginInitialize() {
7373
* @param callbackContext The callback context from which we were invoked.
7474
* @return A PluginResult object with a status and message.
7575
*/
76+
@Override
7677
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
7778
PluginResult.Status status = PluginResult.Status.OK;
7879
String result = "";
@@ -86,6 +87,7 @@ else if (action.equals("show")) {
8687
// I recommend we change the name of the Message as spinner/stop is not
8788
// indicative of what this actually does (shows the webview).
8889
cordova.getActivity().runOnUiThread(new Runnable() {
90+
@Override
8991
public void run() {
9092
webView.getPluginManager().postMessage("spinner", "stop");
9193
}
@@ -144,6 +146,7 @@ else if (action.equals("messageChannel")) {
144146
*/
145147
public void clearCache() {
146148
cordova.getActivity().runOnUiThread(new Runnable() {
149+
@Override
147150
public void run() {
148151
webView.clearCache();
149152
}
@@ -215,6 +218,7 @@ else if (value.getClass().equals(Integer.class)) {
215218
*/
216219
public void clearHistory() {
217220
cordova.getActivity().runOnUiThread(new Runnable() {
221+
@Override
218222
public void run() {
219223
webView.clearHistory();
220224
}
@@ -227,6 +231,7 @@ public void run() {
227231
*/
228232
public void backHistory() {
229233
cordova.getActivity().runOnUiThread(new Runnable() {
234+
@Override
230235
public void run() {
231236
webView.backHistory();
232237
}
@@ -353,6 +358,7 @@ private void sendEventMessage(PluginResult payload) {
353358
* Unregister the receiver
354359
*
355360
*/
361+
@Override
356362
public void onDestroy()
357363
{
358364
webView.getContext().unregisterReceiver(this.telephonyReceiver);

framework/src/org/apache/cordova/NativeToJsMessageQueue.java

+4
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public LoadUrlBridgeMode(CordovaWebViewEngine engine, CordovaInterface cordova)
302302
@Override
303303
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
304304
cordova.getActivity().runOnUiThread(new Runnable() {
305+
@Override
305306
public void run() {
306307
String js = queue.popAndEncodeAsJs();
307308
if (js != null) {
@@ -330,6 +331,7 @@ public OnlineEventsBridgeMode(OnlineEventsBridgeModeDelegate delegate) {
330331
@Override
331332
public void reset() {
332333
delegate.runOnUiThread(new Runnable() {
334+
@Override
333335
public void run() {
334336
online = false;
335337
// If the following call triggers a notifyOfFlush, then ignore it.
@@ -342,6 +344,7 @@ public void run() {
342344
@Override
343345
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
344346
delegate.runOnUiThread(new Runnable() {
347+
@Override
345348
public void run() {
346349
if (!queue.isEmpty()) {
347350
ignoreNextFlush = false;
@@ -372,6 +375,7 @@ public EvalBridgeMode(CordovaWebViewEngine engine, CordovaInterface cordova) {
372375
@Override
373376
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
374377
cordova.getActivity().runOnUiThread(new Runnable() {
378+
@Override
375379
public void run() {
376380
String js = queue.popAndEncodeAsJs();
377381
if (js != null) {

framework/src/org/apache/cordova/engine/SystemCookieManager.java

+5
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,27 @@ public void setAcceptFileSchemeCookies() {
4141
cookieManager.setAcceptFileSchemeCookies(true);
4242
}
4343

44+
@Override
4445
public void setCookiesEnabled(boolean accept) {
4546
cookieManager.setAcceptCookie(accept);
4647
}
4748

49+
@Override
4850
public void setCookie(final String url, final String value) {
4951
cookieManager.setCookie(url, value);
5052
}
5153

54+
@Override
5255
public String getCookie(final String url) {
5356
return cookieManager.getCookie(url);
5457
}
5558

59+
@Override
5660
public void clearCookies() {
5761
cookieManager.removeAllCookies(null);
5862
}
5963

64+
@Override
6065
public void flush() {
6166
cookieManager.flush();
6267
}

0 commit comments

Comments
 (0)