Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b3086a

Browse files
committed
Java: Fix capitalization of JxBrowser
1 parent 1ebc9f4 commit 5b3086a

8 files changed

Lines changed: 34 additions & 34 deletions

java/ql/src/experimental/Security/CWE/CWE-295/JXBrowserWithoutCertValidation.java renamed to java/ql/src/experimental/Security/CWE/CWE-295/JxBrowserWithoutCertValidation.java

File renamed without changes.

java/ql/src/experimental/Security/CWE/CWE-295/JXBrowserWithoutCertValidation.qhelp renamed to java/ql/src/experimental/Security/CWE/CWE-295/JxBrowserWithoutCertValidation.qhelp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<qhelp>
55

66
<overview>
7-
<p>JXBrowser is a Java library that allows to embed the Chromium browser inside Java applications.
8-
The version 6.x.x by default ignores any HTTPS certificate errors thereby allowing man-in-the-middle attacks.
7+
<p>JxBrowser is a Java library that allows to embed the Chromium browser inside Java applications.
8+
Versions smaller than 6.24 by default ignore any HTTPS certificate errors thereby allowing man-in-the-middle attacks.
99
</p>
1010
</overview>
1111

1212
<recommendation>
1313
<p>Do either of these:
14-
<li>Update to version 7.x.x as it now correctly rejects certificate errors by default.</li>
14+
<li>Update to version 6.24 or 7.x.x as these correctly reject certificate errors by default.</li>
1515
<li>Add a custom implementation of the <code>LoadHandler</code> interface whose <code>onCertificateError</code> method always returns <b>true</b> indicating that loading should be cancelled.
1616
Then use the <code>setLoadHandler</code> method with your custom <code>LoadHandler</code> on every <code>Browser</code> you use.</li>
1717
</p>
@@ -20,12 +20,12 @@ Then use the <code>setLoadHandler</code> method with your custom <code>LoadHandl
2020
<example>
2121
<p>The following two examples show two ways of using a <code>Browser</code>. In the 'BAD' case,
2222
all certificate errors are ignored. In the 'GOOD' case, certificate errors are rejected.</p>
23-
<sample src="JXBrowserWithoutCertValidation.java" />
23+
<sample src="JxBrowserWithoutCertValidation.java" />
2424
</example>
2525

2626
<references>
2727
<li>Teamdev:
28-
<a href="https://www.teamdev.com/downloads/jxbrowser/javadoc/com/teamdev/jxbrowser/chromium/LoadHandler.html#onCertificateError-com.teamdev.jxbrowser.chromium.CertificateErrorParams-">
29-
Javadoc for the LoadHandler#onCertificateError method</a>.</li>
28+
<a href="https://jxbrowser.support.teamdev.com/support/discussions/topics/9000051708">
29+
Changelog of JxBrowser 6.24</a>.</li>
3030
</references>
3131
</qhelp>

java/ql/src/experimental/Security/CWE/CWE-295/JXBrowserWithoutCertValidation.ql renamed to java/ql/src/experimental/Security/CWE/CWE-295/JxBrowserWithoutCertValidation.ql

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name JXBrowser with disabled certificate validation
3-
* @description Insecure configuration of JXBrowser disables certificate validation making the app vulnerable to man-in-the-middle attacks.
2+
* @name JxBrowser with disabled certificate validation
3+
* @description Insecure configuration of JxBrowser disables certificate validation making the app vulnerable to man-in-the-middle attacks.
44
* @kind problem
55
* @id java/jxbrowser/disabled-certificate-validation
66
* @tags security
@@ -12,33 +12,33 @@ import semmle.code.java.security.Encryption
1212
import semmle.code.java.dataflow.TaintTracking
1313

1414
/*
15-
* This query is version specific to JXBrowser < 6.24. The version is indirectly detected.
15+
* This query is version specific to JxBrowser < 6.24. The version is indirectly detected.
1616
* In version 6.x.x the `Browser` class is in a different package compared to version 7.x.x.
1717
*/
1818

1919
/**
20-
* Holds if a safe JXBrowser 6.x.x version is used, such as version 6.24.
20+
* Holds if a safe JxBrowser 6.x.x version is used, such as version 6.24.
2121
* This is detected by the the presence of the `addBoundsListener` in the `Browser` class.
2222
*/
23-
private predicate isSafeJXBrowserVersion() {
24-
exists(Method m | m.getDeclaringType() instanceof JXBrowser | m.hasName("addBoundsListener"))
23+
private predicate isSafeJxBrowserVersion() {
24+
exists(Method m | m.getDeclaringType() instanceof JxBrowser | m.hasName("addBoundsListener"))
2525
}
2626

2727
/** The `com.teamdev.jxbrowser.chromium.Browser` class. */
28-
private class JXBrowser extends RefType {
29-
JXBrowser() { this.hasQualifiedName("com.teamdev.jxbrowser.chromium", "Browser") }
28+
private class JxBrowser extends RefType {
29+
JxBrowser() { this.hasQualifiedName("com.teamdev.jxbrowser.chromium", "Browser") }
3030
}
3131

3232
/** The `setLoadHandler` method on the `com.teamdev.jxbrowser.chromium.Browser` class. */
33-
private class JXBrowserSetLoadHandler extends Method {
34-
JXBrowserSetLoadHandler() {
35-
this.hasName("setLoadHandler") and this.getDeclaringType() instanceof JXBrowser
33+
private class JxBrowserSetLoadHandler extends Method {
34+
JxBrowserSetLoadHandler() {
35+
this.hasName("setLoadHandler") and this.getDeclaringType() instanceof JxBrowser
3636
}
3737
}
3838

3939
/** The `com.teamdev.jxbrowser.chromium.LoadHandler` interface. */
40-
private class JXBrowserLoadHandler extends RefType {
41-
JXBrowserLoadHandler() { this.hasQualifiedName("com.teamdev.jxbrowser.chromium", "LoadHandler") }
40+
private class JxBrowserLoadHandler extends RefType {
41+
JxBrowserLoadHandler() { this.hasQualifiedName("com.teamdev.jxbrowser.chromium", "LoadHandler") }
4242
}
4343

4444
private predicate isOnCertificateErrorMethodSafe(Method m) {
@@ -48,35 +48,35 @@ private predicate isOnCertificateErrorMethodSafe(Method m) {
4848
}
4949

5050
/** A class that securely implements the `com.teamdev.jxbrowser.chromium.LoadHandler` interface. */
51-
private class JXBrowserSafeLoadHandler extends RefType {
52-
JXBrowserSafeLoadHandler() {
53-
this.getASupertype() instanceof JXBrowserLoadHandler and
51+
private class JxBrowserSafeLoadHandler extends RefType {
52+
JxBrowserSafeLoadHandler() {
53+
this.getASupertype() instanceof JxBrowserLoadHandler and
5454
exists(Method m | m.hasName("onCertificateError") and m.getDeclaringType() = this |
5555
isOnCertificateErrorMethodSafe(m)
5656
)
5757
}
5858
}
5959

60-
private class JXBrowserTaintTracking extends TaintTracking::Configuration {
61-
JXBrowserTaintTracking() { this = "JXBrowserTaintTracking" }
60+
private class JxBrowserTaintTracking extends TaintTracking::Configuration {
61+
JxBrowserTaintTracking() { this = "JxBrowserTaintTracking" }
6262

6363
override predicate isSource(DataFlow::Node src) {
64-
exists(ClassInstanceExpr newJXBrowser | newJXBrowser.getConstructedType() instanceof JXBrowser |
65-
newJXBrowser = src.asExpr()
64+
exists(ClassInstanceExpr newJxBrowser | newJxBrowser.getConstructedType() instanceof JxBrowser |
65+
newJxBrowser = src.asExpr()
6666
)
6767
}
6868

6969
override predicate isSink(DataFlow::Node sink) {
70-
exists(MethodAccess ma | ma.getMethod() instanceof JXBrowserSetLoadHandler |
71-
ma.getArgument(0).getType() instanceof JXBrowserSafeLoadHandler and
70+
exists(MethodAccess ma | ma.getMethod() instanceof JxBrowserSetLoadHandler |
71+
ma.getArgument(0).getType() instanceof JxBrowserSafeLoadHandler and
7272
ma.getQualifier() = sink.asExpr()
7373
)
7474
}
7575
}
7676

77-
from JXBrowserTaintTracking cfg, DataFlow::Node src
77+
from JxBrowserTaintTracking cfg, DataFlow::Node src
7878
where
7979
cfg.isSource(src) and
8080
not cfg.hasFlow(src, _) and
81-
not isSafeJXBrowserVersion()
82-
select src, "This JXBrowser instance allows man-in-the-middle attacks."
81+
not isSafeJxBrowserVersion()
82+
select src, "This JxBrowser instance allows man-in-the-middle attacks."

java/ql/test/experimental/query-tests/security/CWE-295/JXBrowserWithoutCertValidation.expected

Lines changed: 0 additions & 1 deletion
This file was deleted.

java/ql/test/experimental/query-tests/security/CWE-295/JXBrowserWithoutCertValidation.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| JxBrowserWithoutCertValidation.java:17:27:17:39 | new Browser(...) | This JxBrowser instance allows man-in-the-middle attacks. |

java/ql/test/experimental/query-tests/security/CWE-295/JXBrowserWithoutCertValidation.java renamed to java/ql/test/experimental/query-tests/security/CWE-295/JxBrowserWithoutCertValidation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.teamdev.jxbrowser.chromium.LoadParams;
44
import com.teamdev.jxbrowser.chromium.CertificateErrorParams;
55

6-
public class JXBrowserWithoutCertValidation {
6+
public class JxBrowserWithoutCertValidation {
77

88
public static void main(String[] args) {
99

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental/Security/CWE/CWE-295/JxBrowserWithoutCertValidation.ql

0 commit comments

Comments
 (0)