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): switch back to default if remote config stop sending the security rule file #10030

Merged

Conversation

christophe-papazian
Copy link
Contributor

@christophe-papazian christophe-papazian commented Aug 1, 2024

Security rule file is provided by ASM_DD through remote config.
This PR fix an issue where the WAF could be disabled if remote config was deleting or deprecating the ASM_DD rule file.

After that PR, the WAF will stay enabled with the default recommended rule file.

Also

  • rename rules attribute to the more precise rule_filename in AppSecSpanProcessor
  • add a unit test to ensure that we never send an empty rule list to the waf
  • this will also be tested with the new system tests : add rc test for ASM_DD rules system-tests#2839

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 Aug 1, 2024
christophe-papazian and others added 2 commits August 1, 2024 17:17
…ssh://github.com/DataDog/dd-trace-py into christophe-papazian/fix_rc_asm_dd_delete_rule_file
Copy link
Contributor

github-actions bot commented Aug 1, 2024

CODEOWNERS have been resolved as:

releasenotes/notes/fix_rc_asm_dd_no_file-37e6f733583e334c.yaml          @DataDog/apm-python
ddtrace/appsec/_processor.py                                            @DataDog/asm-python
ddtrace/appsec/_remoteconfiguration.py                                  @DataDog/asm-python
tests/appsec/appsec/test_processor.py                                   @DataDog/asm-python
tests/appsec/appsec/test_remoteconfiguration.py                         @DataDog/asm-python

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

datadog-dd-trace-py-rkomorn bot commented Aug 1, 2024

Datadog Report

Branch report: christophe-papazian/fix_rc_asm_dd_delete_rule_file
Commit report: 11285ea
Test service: dd-trace-py

✅ 0 Failed, 109870 Passed, 3967 Skipped, 5m 50.98s Total duration (39m 47.43s time saved)

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 20.83333% with 19 lines in your changes missing coverage. Please review.

Project coverage is 10.54%. Comparing base (eb99173) to head (11285ea).
Report is 34 commits behind head on main.

Files Patch % Lines
tests/appsec/appsec/test_remoteconfiguration.py 0.00% 10 Missing ⚠️
ddtrace/appsec/_processor.py 55.55% 4 Missing ⚠️
ddtrace/appsec/_remoteconfiguration.py 0.00% 4 Missing ⚠️
tests/appsec/appsec/test_processor.py 0.00% 1 Missing ⚠️

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

HEAD has 1 upload less than BASE
Flag BASE (eb99173) HEAD (11285ea)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #10030       +/-   ##
===========================================
- Coverage   73.94%   10.54%   -63.40%     
===========================================
  Files        1402     1378       -24     
  Lines      130639   128969     -1670     
===========================================
- Hits        96598    13599    -82999     
- Misses      34041   115370    +81329     

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

@pr-commenter
Copy link

pr-commenter bot commented Aug 1, 2024

Benchmarks

Benchmark execution time: 2024-08-01 16:59:00

Comparing candidate commit 54301db in PR branch christophe-papazian/fix_rc_asm_dd_delete_rule_file with baseline commit 919bd7b in branch main.

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

@christophe-papazian christophe-papazian changed the title fix(asm): switch back to the default recommended rule file if remote config stop sending the security rule file. fix(asm): switch back to default if remote config stop sending the security rule file. Aug 2, 2024
@christophe-papazian christophe-papazian changed the title fix(asm): switch back to default if remote config stop sending the security rule file. fix(asm): switch back to default if remote config stop sending the security rule file Aug 2, 2024
@christophe-papazian christophe-papazian marked this pull request as ready for review August 2, 2024 07:56
@christophe-papazian christophe-papazian enabled auto-merge (squash) August 2, 2024 08:03
@christophe-papazian christophe-papazian merged commit bc50e9c into main Aug 2, 2024
76 of 81 checks passed
@christophe-papazian christophe-papazian deleted the christophe-papazian/fix_rc_asm_dd_delete_rule_file branch August 2, 2024 08:36
Copy link
Contributor

github-actions bot commented Aug 2, 2024

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-10030-to-2.9
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 bc50e9cd69c4a21a101e11bf250a7904dc6b6937
# Push it to GitHub
git push --set-upstream origin backport-10030-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-10030-to-2.9.

Copy link
Contributor

github-actions bot commented Aug 2, 2024

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-10030-to-2.10
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 bc50e9cd69c4a21a101e11bf250a7904dc6b6937
# Push it to GitHub
git push --set-upstream origin backport-10030-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-10030-to-2.10.

christophe-papazian added a commit that referenced this pull request Aug 2, 2024
…curity rule file (#10030)

Security rule file is provided by ASM_DD through remote config.
This PR fix an issue where the WAF could be disabled if remote config
was deleting or deprecating the ASM_DD rule file.

After that PR, the WAF will stay enabled with the default recommended
rule file.

Also
- rename `rules` attribute to the more precise `rule_filename` in
`AppSecSpanProcessor`
- add a unit test to ensure that we never send an empty rule list to the
waf
- this will also be tested with the new system tests :
DataDog/system-tests#2839

APPSEC-54105

- [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 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)

(cherry picked from commit bc50e9c)
romainkomorndatadog pushed a commit that referenced this pull request Aug 2, 2024
…curity rule file [backport 2.10] (#10052)

backporting #10030

APPSEC-54105

(cherry picked from commit bc50e9c)

## 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)
github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
…curity rule file [backport 2.10] (#10052)

backporting #10030

APPSEC-54105

(cherry picked from commit bc50e9c)

## 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)

(cherry picked from commit e3f9004)
christophe-papazian added a commit that referenced this pull request Aug 2, 2024
…ssor (#10056)

Add a little more coverage on
#10030 to ensure that the
rule structure is not modified by new features.

## 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
- [ ] 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 Aug 2, 2024
…curity rule file [backport 2.9] (#10053)

Backport e3f9004 from #10052 to 2.9.

backporting #10030

APPSEC-54105

(cherry picked from commit bc50e9c)

## 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)

Co-authored-by: Christophe Papazian <114495376+christophe-papazian@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASM Application Security Monitoring backport 2.9 backport 2.10 bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants