Skip to content

feat(asm): new user event sdk #13251

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

Merged
merged 20 commits into from
Apr 30, 2025

Conversation

christophe-papazian
Copy link
Contributor

@christophe-papazian christophe-papazian commented Apr 22, 2025

A new public SDK for ATO/user events for AAP.
Available with

from ddtrace.appsec import track_user_sdk

# to track successful login attempts
track_user_sdk.track_login_success(login, user_id:optional, metadata:optional)
# to track failed login attempts
track_user_sdk.track_login_failure(login, exists, user_id:optional, metadata:optional)
# to track any custom event
track_user_sdk.track_custom_event(event, metatada)
# to track signup events
track_user_sdk.track_signup(login,  user_id:optional, success:optional, metadata:optional)
# to track authentified user (usually in middleware, using auth token)
track_user_sdk.track_user(login,  user_id, session_id:optional, metadata:optional)

Also:

  • minor fixes and improvements in current ATO support.
  • threat tests added for sdk (span tags and telemetry unit tests)

This will be validated in system tests with DataDog/system-tests#4565

The documentation page to be updated is https://docs.datadoghq.com/security/application_security/threats/add-user-info/?tab=loginsuccess&code-lang=python

APPSEC-56663

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 changelog/no-changelog A changelog entry is not required for this PR. ASM Application Security Monitoring labels Apr 22, 2025
Copy link
Contributor

github-actions bot commented Apr 22, 2025

CODEOWNERS have been resolved as:

ddtrace/appsec/track_user_sdk.py                                        @DataDog/asm-python
releasenotes/notes/ato_sdk_v2-35c17dc258c5b690.yaml                     @DataDog/apm-python
ddtrace/appsec/_metrics.py                                              @DataDog/asm-python
ddtrace/appsec/_trace_utils.py                                          @DataDog/asm-python
tests/appsec/contrib_appsec/django_app/urls.py                          @DataDog/asm-python
tests/appsec/contrib_appsec/fastapi_app/app.py                          @DataDog/asm-python
tests/appsec/contrib_appsec/flask_app/app.py                            @DataDog/asm-python
tests/appsec/contrib_appsec/utils.py                                    @DataDog/asm-python

@christophe-papazian christophe-papazian removed the changelog/no-changelog A changelog entry is not required for this PR. label Apr 22, 2025
Copy link
Contributor

github-actions bot commented Apr 22, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 233 ± 4 ms.

The average import time from base is: 233 ± 2 ms.

The import time difference between this PR and base is: -0.4 ± 0.1 ms.

The difference is not statistically significant (z = -2.45).

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 1.827 ms (0.79%)
ddtrace.bootstrap.sitecustomize 1.160 ms (0.50%)
ddtrace.bootstrap.preload 1.160 ms (0.50%)
ddtrace.internal.products 1.160 ms (0.50%)
ddtrace.internal.remoteconfig.client 0.584 ms (0.25%)
ddtrace 0.667 ms (0.29%)

@pr-commenter
Copy link

pr-commenter bot commented Apr 22, 2025

Benchmarks

Benchmark execution time: 2025-04-29 12:21:07

Comparing candidate commit d8b2c8d in PR branch christophe-papazian/add_ato_sdk_v2 with baseline commit 5c7228a in branch main.

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

scenario:iast_aspects-format_map_aspect

  • 🟥 execution_time [+274.607ns; +408.874ns] or [+8.429%; +12.551%]

scenario:iast_aspects-ospathsplitdrive_aspect

  • 🟥 execution_time [+418.953ns; +514.235ns] or [+11.159%; +13.697%]

@christophe-papazian christophe-papazian marked this pull request as ready for review April 28, 2025 15:39
@christophe-papazian christophe-papazian requested a review from a team as a code owner April 28, 2025 15:39
@christophe-papazian christophe-papazian requested a review from a team as a code owner April 28, 2025 15:39
@christophe-papazian christophe-papazian enabled auto-merge (squash) April 30, 2025 11:12
@christophe-papazian christophe-papazian merged commit 7ac4431 into main Apr 30, 2025
411 checks passed
@christophe-papazian christophe-papazian deleted the christophe-papazian/add_ato_sdk_v2 branch April 30, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASM Application Security Monitoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants