rspec/rules/S5144/php/rule.adoc
2022-02-04 16:28:24 +00:00

42 lines
648 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
[source,php]
----
$url = $_GET["url"];
$resp = file_get_contents($url); // Noncompliant
// ...
----
== Compliant Solution
[source,php]
----
$whitelist = array(
"www.example.com",
"example.com"
);
$url = $_GET["url"];
$parsed_url = parse_url($url);
if (in_array($parsed_url['host'], $whitelist)) {
$resp = file_get_contents($url);
// ...
}
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]