Skip to content

Commit 49063ac

Browse files
committed
Rust: Cut down the example for readability.
1 parent dcae0ef commit 49063ac

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

rust/ql/src/queries/security/CWE-295/DisabledCertificateCheck.qhelp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Do not set <code>danger_accept_invalid_certs</code> or <code>danger_accept_inval
1717

1818
<example>
1919
<p>
20-
The following code snippet shows a function that creates a TLS or HTTP client with certificate verification disabled:
20+
The following code snippet shows a function that creates an HTTP client with certificate verification disabled:
2121
</p>
2222
<sample src="DisabledCertificateCheckBad.rs"/>
2323
<p>
24-
In production code, always configure clients to verify certificates and hostnames:
24+
In production code, always configure clients to verify certificates:
2525
</p>
2626
<sample src="DisabledCertificateCheckGood.rs"/>
2727
</example>

rust/ql/src/queries/security/CWE-295/DisabledCertificateCheckBad.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
// BAD: Disabling certificate validation in Rust
22

3-
// Using native_tls
4-
let _client = native_tls::TlsConnector::builder()
5-
.danger_accept_invalid_certs(true) // disables certificate validation
6-
.build()
7-
.unwrap();
8-
9-
// Using reqwest
103
let _client = reqwest::Client::builder()
114
.danger_accept_invalid_certs(true) // disables certificate validation
125
.build()
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
// GOOD: Certificate validation is enabled (default)
22

3-
// Using native_tls
4-
let _client = native_tls::TlsConnector::builder()
5-
.danger_accept_invalid_certs(false) // certificate validation enabled
6-
.build()
7-
.unwrap();
8-
9-
// Using reqwest
103
let _client = reqwest::Client::builder()
11-
.danger_accept_invalid_certs(false) // certificate validation enabled
4+
.danger_accept_invalid_certs(false) // certificate validation enabled explicitly
125
.build()
136
.unwrap();
147

15-
// Or simply use the default builder (safe)
16-
let _client = native_tls::TlsConnector::builder()
8+
let _client = native_tls::TlsConnector::builder() // certificate validation enabled by default
179
.build()
1810
.unwrap();

0 commit comments

Comments
 (0)