bridgecrewio / yor

Extensible auto-tagger for your IaC files. The ultimate way to link entities in the cloud back to the codified resource which created it.
https://www.yor.io
Apache License 2.0
819 stars 123 forks source link

`MuteOutputBlock()` globally mutes output, surpressing output from all other concurrent tasks #449

Closed BHoggs closed 7 months ago

BHoggs commented 10 months ago

Describe the bug It appears the intent of MuteOutputBlock() is to run certain debug functions and surpress their output, however the current implementation has the side effect of muting all output from all other operations.

I noticed this as I was getting inconsistent warning messages when yor is running. This appears to be because they're getting surpressed while another go routine is using MuteOutputBlock()

https://github.com/bridgecrewio/yor/blob/3e30ff383f4bde7b818626da5c77f0372ba1675e/src/common/logger/logging_service.go#L120C34-L120C34

To Reproduce Steps to reproduce the behavior:

  1. Go to <unfortunately cannot share my terraform code, but hopefully any large enough project will trigger some warnings>
  2. Run cli command yor tag --tag-local-modules -d .
  3. Repeat step 2 multiple times
  4. Observe differences in warnings

Expected behavior I expect to get the same warning outputs each time I run yor on the same code

Desktop (please complete the following information):

Additional context Add any other context about the problem here (e.g. code snippets). https://github.com/bridgecrewio/yor/blob/3e30ff383f4bde7b818626da5c77f0372ba1675e/src/common/logger/logging_service.go#L120C34-L120C34

ChanochShayner commented 9 months ago

Hey @BHoggs thank you for reporting on this The fix should be something like - temporarily setting the Logger.disabled flag to true only for the duration of the provided function (fn). After the function execution is complete, the original mute state is restored.

It will be a nice contribution :)

@Saarett FYI

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.