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(iast): set iast instrumented metrics at runtime, not at request time #8816

Merged
merged 6 commits into from
Apr 2, 2024

Conversation

avara1986
Copy link
Member

@avara1986 avara1986 commented Apr 1, 2024

The instrumented metrics are independent of whether IAST is active in a request or not; they only depend on whether instrumentation is applied (which should only depend on DD_IAST_ENABLED=true). There are two sets of metrics: those with "instrumented" and those with "executed":

  • Instrumented metrics: A point has been patched where cookies (for example) can be tainted. It doesn't matter whether it is executed or not, the sampling rate, or whether there are cookies or not.
  • Executed metrics: The callback for handling cookies is actually executed.

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.
  • If change touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • 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

@avara1986 avara1986 added changelog/no-changelog A changelog entry is not required for this PR. ASM Application Security Monitoring labels Apr 1, 2024
@avara1986 avara1986 changed the title fix: Set IAST Instrumented metrics at runtime, nor at request time fix: set iast Instrumented metrics at runtime, nor at request time Apr 1, 2024
@datadog-dd-trace-py-rkomorn
Copy link

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

Datadog Report

Branch report: avara1986/APPSEC-52379-iast_instrumented_metrics
Commit report: dd06ba3
Test service: dd-trace-py

✅ 0 Failed, 55972 Passed, 55517 Skipped, 1h 2m 10.82s Total duration (52m 30.92s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Apr 1, 2024

Benchmarks

Benchmark execution time: 2024-04-02 07:27:46

Comparing candidate commit dd06ba3 in PR branch avara1986/APPSEC-52379-iast_instrumented_metrics with baseline commit b374a5a in branch main.

Found 3 performance improvements and 3 performance regressions! Performance is the same for 195 metrics, 9 unstable metrics.

scenario:flasksimple-appsec-telemetry

  • 🟥 execution_time [+223.734µs; +278.509µs] or [+3.564%; +4.436%]

scenario:httppropagationextract-b3_headers

  • 🟥 max_rss_usage [+701.819KB; +773.151KB] or [+3.322%; +3.659%]

scenario:httppropagationextract-invalid_priority_header

  • 🟥 max_rss_usage [+476.527KB; +844.024KB] or [+2.246%; +3.978%]

scenario:httppropagationextract-none_propagation_style

  • 🟩 max_rss_usage [-781.388KB; -695.220KB] or [-3.575%; -3.181%]

scenario:sethttpmeta-obfuscation-disabled

  • 🟩 max_rss_usage [-760.390KB; -598.663KB] or [-3.436%; -2.706%]

scenario:sethttpmeta-obfuscation-worst-case-explicit-query

  • 🟩 max_rss_usage [-777.000KB; -528.805KB] or [-3.473%; -2.364%]

@avara1986 avara1986 force-pushed the avara1986/APPSEC-52379-iast_instrumented_metrics branch from 2449828 to d0528d0 Compare April 1, 2024 15:26
@gnufede gnufede changed the title fix: set iast Instrumented metrics at runtime, nor at request time fix(iast): set iast instrumented metrics at runtime, not at request time Apr 1, 2024
@gnufede gnufede marked this pull request as ready for review April 1, 2024 18:46
@gnufede gnufede requested a review from a team as a code owner April 1, 2024 18:46
@gnufede gnufede enabled auto-merge (squash) April 2, 2024 07:44
@gnufede gnufede merged commit 36d42bf into main Apr 2, 2024
115 of 119 checks passed
@gnufede gnufede deleted the avara1986/APPSEC-52379-iast_instrumented_metrics branch April 2, 2024 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASM Application Security Monitoring changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants