Avoid exposure of sensitive data
defmodule MySensitiveInfo do
@password 'sensitive_password'
@api_key 'API_KEY'
end
The source code contains sensitive data, including a password and an API key, hardcoded in the code. This is a bad practice as it exposes sensitive information directly in the source code, making it accessible to anyone who can access this code.
defmodule MySensitiveInfo do
@password System.get_env('PASSWORD')
@api_key System.get_env('API_KEY')
end
The revised code now retrieves sensitive data from environment variables, which are set outside of the application and not exposed in the source code. This avoids the direct exposure of sensitive information in the source code.