Avoid exposure of real user's personal information stored in the source code
defmodule MyApp.UserController do
use MyApp.Web, :controller
def show(conn, %{"id" => id}) do
user = %{id: "real_id", phone: "real_phone_number"}
render(conn, "show.json", user: user)
end
end
The insecure code directly uses real personal information (like ID numbers and phone numbers) within the source code. This could lead to a serious data breach, where personal information is leaked, and could be used for malicious purposes such as social engineering attacks.
defmodule MyApp.UserController do
use MyApp.Web, :controller
def show(conn, %{"id" => id}) do
user = %{id: System.get_env("USER_ID"), phone: System.get_env("PHONE_NUMBER")}
render(conn, "show.json", user: user)
end
end
The secure code uses environment variables instead of hard-coding the personal information. It ensures that personal information is not directly exposed in the source code, thereby preventing potential data breaches.