rspec/rules/S5167/java/rule.adoc
2020-06-30 17:16:12 +02:00

27 lines
630 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
----
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String value = req.getParameter("value");
resp.addHeader("X-Header", value); // Noncompliant
}
----
== Compliant Solution
----
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String value = req.getParameter("value");
String whitelist = "safevalue1 safevalue2";
if (!whitelist.contains(value))
throw new IOException();
resp.addHeader("X-Header", value); // Compliant
}
----
include::../see.adoc[]