Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to reset AppSec settings when calling Datadog.configuration.reset! #2910

Merged
merged 3 commits into from
Jun 19, 2023

Conversation

GustavoCaso
Copy link
Member

What does this PR do?

Trying to fix those annoying leaky specs for AppSec regarding if is runing or not 😡

Motivation

Additional Notes

How to test the change?

@GustavoCaso GustavoCaso requested a review from a team June 16, 2023 12:02
@github-actions github-actions bot added the dev/testing Involves testing processes (e.g. RSpec) label Jun 16, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #2910 (0594c9b) into master (65d3dde) will decrease coverage by 0.13%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2910      +/-   ##
==========================================
- Coverage   98.11%   97.98%   -0.13%     
==========================================
  Files        1266     1274       +8     
  Lines       70152    70319     +167     
  Branches     3187     3229      +42     
==========================================
+ Hits        68827    68903      +76     
- Misses       1325     1416      +91     

see 60 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment on lines 913 to 914
Datadog.configuration.reset!
Datadog.configuration.appsec.send(:reset!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is... weird. Should Datadog.configuration.reset! reset all of the configuration, including appsec?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the reasons I mentioned to you that I want to write an RFC for having a core configuration. AppSec has its own way of adding extensions.

So Ideally yes, but at the moment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed appsec configuration is... in flow I guess. Can I convince you to add Datadog.configuration.appsec.send(:reset!) to Datadog::Configuration#reset!?

While doing that doesn't solve tech debt, it seems reasonable to do until we can do a better solution.

(But, on the other hand, if I can't convince you, and just to clarify, I don't think it's a blocking issue, happy to approve either way, if we really have to )

@github-actions github-actions bot added core Involves Datadog core libraries and removed dev/testing Involves testing processes (e.g. RSpec) labels Jun 19, 2023
@GustavoCaso GustavoCaso changed the title fix possibel leaky spesc for appsec enabled value Make sure to reset AppSec settings when calling Datadog.configuration.reset! Jun 19, 2023
@@ -91,6 +91,7 @@ def dig(*options)

def reset!
reset_options!
Datadog::AppSec.settings.send(:reset!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this change. Just in case, let me ask -- are we sure we can always call this method on Datadog::Appsec?

E.g. I seem to remember a few cases where the constants were not loaded in some cases and we need to add a few defined?(...) checks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only case I can think of is when people follow the CI documentation since they only require datadog/ci.

I'm not sure how many times people would call reset! on those cases, but I will add the defined? just in case

Copy link
Member Author

@GustavoCaso GustavoCaso Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done fa033c3

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@GustavoCaso GustavoCaso merged commit a734980 into master Jun 19, 2023
@GustavoCaso GustavoCaso deleted the fix-possible-leaky-specs branch June 19, 2023 12:03
@github-actions github-actions bot added this to the 1.13.0 milestone Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants