stefanchrobot

stefanchrobot

I’m trying to prevent leaking of application secrets and personally identifiable information (PIIs) into logs. One thing is obviously making sure that we don’t log that kind of data explicitly. But the other part is taming the built-in error reporters.

When my application was first deployed to the servers, there was a misconfiguration and it crashed badly. While that happened, the error reporter logged the state of a supervisor process and the last received message. The state contained API keys. If I write a simple GenServer that crashes, it’s pretty easy to reproduce the log entry with the last message. For some reason, I’m unable to make the error reporter log the process state.

I have a few questions around this:

  1. When is the state of the process logged?
  2. Is it possible to prevent logging of the last message and the state of the process?
  3. Is it possible to prevent logging of general errors (match error might leak sensitive data too)?

I’m also a bit confused about the documentation. Since I’m on OTP 21+, the docs state that:

SASL Reports
By SASL reports we mean supervisor reports, crash reports and progress reports.
Prior to Erlang/OTP 21.0, these reports were only logged when the SASL application was running, and they were printed trough SASL’s own event handlers sasl_report_tty_h and sasl_report_file_h. (…) Due to the specific event handlers, the output format slightly differed from other log events.
As of Erlang/OTP 21.0, the concept of SASL reports is removed, meaning that the default behaviour is as follows:

  • Supervisor reports, crash reports, and progress reports are no longer connected to the SASL application.
  • Supervisor reports and crash reports are issued as error level log events, and are logged through the default handler started by Kernel. (…)
  • The output format is the same for all log events.

On the other hand, the Elixir’s Logger docs state that I should set the :handle_otp_reports and :handle_sasl_reports options to true and start the :sasl application before the :logger to handle the process crash reports as usual Elixir logs.

  1. Is this still true when running on OTP 21+?

First 3 of 3 Posts Switch mode

blatyo

blatyo

Conduit Core Team

I don’t have the direct answers you’re looking for. However, I wanted to point out custom struct inspections, which is a relatively new feature. It allows you to specify which fields show when a struct is inspected. This applies to logs, because when state is printed to logs, it is inspected first.

stefanchrobot

stefanchrobot OP

Thanks! At first I thought that it’s really not the answer I’m looking for. Well, after some thought, it turns out that it actually is! It’s enough to wrap sensitive data in a struct and implement Inspect for it.

mattbaker

mattbaker

Years later I find myself wondering this same question :joy:

We’re not literally starting the SASL app, so do we need the logger handle_sasl option enabled? It seems like no? Curious if anyone ever found a clear answer!

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement