25 lines
423 B
Plaintext
25 lines
423 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
$url = $this->request->getQuery("url");
|
||
|
return $this->redirect($url); // Noncompliant
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
$whitelist = array(
|
||
|
"https://www.sonarsource.com/"
|
||
|
);
|
||
|
$url = $this->request->getQuery("url");
|
||
|
if (in_array($url, $whitelist)) {
|
||
|
return $this->redirect($url);
|
||
|
} else {
|
||
|
throw new ForbiddenException();
|
||
|
}
|
||
|
----
|
||
|
|
||
|
include::../see.adoc[]
|