2020-06-30 12:50:28 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,php]
|
2020-06-30 12:50:28 +02:00
|
|
|
----
|
|
|
|
$url = $_GET["url"];
|
|
|
|
$resp = file_get_contents($url); // Noncompliant
|
|
|
|
// ...
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,php]
|
2020-06-30 12:50:28 +02:00
|
|
|
----
|
|
|
|
$whitelist = array(
|
2022-01-17 17:57:50 +01:00
|
|
|
"www.example.com",
|
|
|
|
"example.com"
|
2020-06-30 12:50:28 +02:00
|
|
|
);
|
2022-01-17 17:57:50 +01:00
|
|
|
|
|
|
|
$url = $_GET["url"];
|
|
|
|
$parsed_url = parse_url($url);
|
|
|
|
|
|
|
|
if (in_array($parsed_url['host'], $whitelist)) {
|
2020-06-30 12:50:28 +02:00
|
|
|
$resp = file_get_contents($url);
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|
2021-09-20 15:38:42 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|