-
Notifications
You must be signed in to change notification settings - Fork 377
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
Add ActiveRecord instrumentation to detect SQLi in AppSec #4167
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4167 +/- ##
==========================================
- Coverage 97.76% 97.74% -0.02%
==========================================
Files 1351 1357 +6
Lines 81733 81950 +217
Branches 4147 4168 +21
==========================================
+ Hits 79904 80106 +202
- Misses 1829 1844 +15 ☔ View full report in Codecov by Sentry. |
BenchmarksBenchmark execution time: 2024-12-02 11:12:20 Comparing candidate commit 971f329 in PR branch Found 1 performance improvements and 1 performance regressions! Performance is the same for 29 metrics, 2 unstable metrics. scenario:profiler - stack collector
scenario:tracing - Propagation - Datadog
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔎 Woah, lots of the digging into internals, congrats on our first RAS(P).
I think we can slightly simplify few bits and pieces on a way.
spec/datadog/appsec/contrib/active_record/multi_adapter_spec.rb
Outdated
Show resolved
Hide resolved
spec/datadog/appsec/contrib/active_record/multi_adapter_spec.rb
Outdated
Show resolved
Hide resolved
spec/datadog/appsec/contrib/active_record/multi_adapter_spec.rb
Outdated
Show resolved
Hide resolved
Datadog ReportBranch report: ✅ 0 Failed, 22036 Passed, 1459 Skipped, 6m 0.31s Total Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏼
What does this PR do?
This PR adds ActiveRecord instrumentation to AppSec for detecting SQL injections.
Motivation:
We want to enable SQL injection detection for users using AppSec. Libddwaf already supports this, so this is just about providing required data to libddwaf.
Change log entry
Add SQL injection detection for ActiveRecord for following adapters:
mysql2
,postgresql
, andsqlite3
Additional Notes:
This is the initial implementation - without blocking, and without passing the SQL span ID with the appsec event.
Passing the span ID of the SQL span is currently not possible without major changes, since tracing creates the SQL span at a later time point than we do our instrumentation.
How to test the change?
This feature can be tested using https://github.com/DataDog/appsec-app-generator (
activerecord-sqli
variant):