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

fix(asm): one click remote config fix #9874

Merged
merged 17 commits into from
Jul 26, 2024

Conversation

christophe-papazian
Copy link
Contributor

@christophe-papazian christophe-papazian commented Jul 19, 2024

This PR fixes a small problem in the Remote Config layer for ASM_FEATURES product.
After that PR:

On the worker side:

  1. if we receive a key in the rc configuration and the value is non empty, it means the value was changed
  2. if we receive a key in the rc configuration and the value is empty, it means the value was deleted
  3. if we don't receive a key in the rc configuration, it means the value was unchanged.

Previously, if the value was a list, it was already the case, but if the value was a dictionary, case 2 and 3 were not correctly separated. Now, an empty dictionary is sent if the key is deleted (case 2).

Also:

APPSEC-54105

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@christophe-papazian christophe-papazian added bug ASM Application Security Monitoring labels Jul 19, 2024
Copy link
Contributor

github-actions bot commented Jul 19, 2024

CODEOWNERS have been resolved as:

releasenotes/notes/rc_asm_features_fix-56fb35d0ca6c5d69.yaml            @DataDog/apm-python
ddtrace/appsec/_remoteconfiguration.py                                  @DataDog/asm-python
ddtrace/internal/remoteconfig/_publishers.py                            @DataDog/remote-config @DataDog/apm-core-python
ddtrace/internal/remoteconfig/client.py                                 @DataDog/remote-config @DataDog/apm-core-python
tests/appsec/appsec/test_remoteconfiguration.py                         @DataDog/asm-python
tests/internal/remoteconfig/test_remoteconfig_client_e2e.py             @DataDog/remote-config @DataDog/apm-core-python

@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Jul 19, 2024

Datadog Report

Branch report: christophe-papazian/fix_one_click_activation
Commit report: d873be7
Test service: dd-trace-py

✅ 0 Failed, 110520 Passed, 43503 Skipped, 23m 32.9s Total duration (8m 24.65s time saved)

@christophe-papazian christophe-papazian changed the title asm enable must always be true or false fix(asm): one click remote config fix Jul 24, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 0.96154% with 103 lines in your changes missing coverage. Please review.

Project coverage is 10.55%. Comparing base (3237351) to head (d873be7).
Report is 5 commits behind head on main.

Files Patch % Lines
...ernal/remoteconfig/test_remoteconfig_client_e2e.py 0.00% 32 Missing ⚠️
tests/appsec/appsec/test_remoteconfiguration.py 0.00% 24 Missing ⚠️
ddtrace/internal/remoteconfig/_publishers.py 0.00% 19 Missing ⚠️
ddtrace/appsec/_remoteconfiguration.py 0.00% 14 Missing ⚠️
ddtrace/internal/remoteconfig/client.py 6.66% 14 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (3237351) and HEAD (d873be7). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3237351) HEAD (d873be7)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #9874       +/-   ##
===========================================
- Coverage   73.94%   10.55%   -63.39%     
===========================================
  Files        1402     1367       -35     
  Lines      130460   128033     -2427     
===========================================
- Hits        96465    13516    -82949     
- Misses      33995   114517    +80522     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pr-commenter
Copy link

pr-commenter bot commented Jul 25, 2024

Benchmarks

Benchmark execution time: 2024-07-26 12:54:58

Comparing candidate commit f866182 in PR branch christophe-papazian/fix_one_click_activation with baseline commit 91af6f6 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 196 metrics, 2 unstable metrics.

@christophe-papazian christophe-papazian merged commit ebf3fa9 into main Jul 26, 2024
77 checks passed
@christophe-papazian christophe-papazian deleted the christophe-papazian/fix_one_click_activation branch July 26, 2024 15:36
Copy link
Contributor

The backport to 2.8 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.8 2.8
# Navigate to the new working tree
cd .worktrees/backport-2.8
# Create a new branch
git switch --create backport-9874-to-2.8
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ebf3fa99ba5cd58a57fa4c5f1950fb6068754645
# Push it to GitHub
git push --set-upstream origin backport-9874-to-2.8
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.8

Then, create a pull request where the base branch is 2.8 and the compare/head branch is backport-9874-to-2.8.

Copy link
Contributor

The backport to 2.9 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.9 2.9
# Navigate to the new working tree
cd .worktrees/backport-2.9
# Create a new branch
git switch --create backport-9874-to-2.9
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ebf3fa99ba5cd58a57fa4c5f1950fb6068754645
# Push it to GitHub
git push --set-upstream origin backport-9874-to-2.9
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.9

Then, create a pull request where the base branch is 2.9 and the compare/head branch is backport-9874-to-2.9.

Copy link
Contributor

The backport to 2.10 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.10 2.10
# Navigate to the new working tree
cd .worktrees/backport-2.10
# Create a new branch
git switch --create backport-9874-to-2.10
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ebf3fa99ba5cd58a57fa4c5f1950fb6068754645
# Push it to GitHub
git push --set-upstream origin backport-9874-to-2.10
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.10

Then, create a pull request where the base branch is 2.10 and the compare/head branch is backport-9874-to-2.10.

christophe-papazian added a commit that referenced this pull request Jul 29, 2024
This PR fixes a small problem in the Remote Config layer for
ASM_FEATURES product.
After that PR:

On the worker side:

1. if we receive a key in the rc configuration and the value is non
empty, it means the value was changed
2. if we receive a key in the rc configuration and the value is empty,
it means the value was deleted
3. if we don't receive a key in the rc configuration, it means the value
was unchanged.

Previously, if the value was a list, it was already the case, but if the
value was a dictionary, case 2 and 3 were not correctly separated. Now,
an empty dictionary is sent if the key is deleted (case 2).

Also:
- small refactor
- update unit tests appropriately
- increase coverage on ASM_FEATURES unit tests for one click
- this PR will also be validated by new system tests

- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Federico Mon <[email protected]>
(cherry picked from commit ebf3fa9)
christophe-papazian added a commit that referenced this pull request Jul 29, 2024
This PR fixes a small problem in the Remote Config layer for
ASM_FEATURES product.
After that PR:

On the worker side:

1. if we receive a key in the rc configuration and the value is non
empty, it means the value was changed
2. if we receive a key in the rc configuration and the value is empty,
it means the value was deleted
3. if we don't receive a key in the rc configuration, it means the value
was unchanged.

Previously, if the value was a list, it was already the case, but if the
value was a dictionary, case 2 and 3 were not correctly separated. Now,
an empty dictionary is sent if the key is deleted (case 2).

Also:
- small refactor
- update unit tests appropriately
- increase coverage on ASM_FEATURES unit tests for one click
- this PR will also be validated by new system tests

- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Federico Mon <[email protected]>
(cherry picked from commit ebf3fa9)
christophe-papazian added a commit that referenced this pull request Jul 29, 2024
Backport to 2.9 of #9874

This PR fixes a small problem in the Remote Config layer for
ASM_FEATURES product.
After that PR:

On the worker side:

1. if we receive a key in the rc configuration and the value is non
empty, it means the value was changed
2. if we receive a key in the rc configuration and the value is empty,
it means the value was deleted
3. if we don't receive a key in the rc configuration, it means the value
was unchanged.

Previously, if the value was a list, it was already the case, but if the
value was a dictionary, case 2 and 3 were not correctly separated. Now,
an empty dictionary is sent if the key is deleted (case 2).

Also:
- small refactor
- update unit tests appropriately
- increase coverage on ASM_FEATURES unit tests for one click
- this PR will also be validated by new system tests

APPSEC-54105

---------

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
christophe-papazian added a commit that referenced this pull request Jul 29, 2024
Backport to 2.10 of #9874

This PR fixes a small problem in the Remote Config layer for
ASM_FEATURES product.
After that PR:

On the worker side:

1. if we receive a key in the rc configuration and the value is non
empty, it means the value was changed
2. if we receive a key in the rc configuration and the value is empty,
it means the value was deleted
3. if we don't receive a key in the rc configuration, it means the value
was unchanged.

Previously, if the value was a list, it was already the case, but if the
value was a dictionary, case 2 and 3 were not correctly separated. Now,
an empty dictionary is sent if the key is deleted (case 2).

APPSEC-54105

Also:
- small refactor
- update unit tests appropriately
- increase coverage on ASM_FEATURES unit tests for one click
- this PR will also be validated by new system tests

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASM Application Security Monitoring bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants