Iast kafka consumer support#3977
Conversation
BenchmarksBenchmark execution time: 2024-02-08 10:23:18 Comparing candidate commit a6cee13 in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 261 metrics, 4 unstable metrics. scenario:plugin-graphql-with-depth-and-collapse-on-18
|
b2bec20 to
4fb8eea
Compare
Overall package sizeSelf size: 6.02 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #3977 +/- ##
==========================================
+ Coverage 85.15% 85.31% +0.15%
==========================================
Files 243 247 +4
Lines 10504 10634 +130
Branches 33 33
==========================================
+ Hits 8945 9072 +127
- Misses 1559 1562 +3 ☔ View full report in Codecov by Sentry. |
6a02a47 to
8472547
Compare
f5cb30f to
168afc3
Compare
| .setCheckpoint(['direction:in', `group:${groupId}`, `topic:${topic}`, 'type:kafka'], span, payloadSize) | ||
| } | ||
|
|
||
| if (aferStartCh.hasSubscribers) { |
There was a problem hiding this comment.
| if (aferStartCh.hasSubscribers) { | |
| if (afterStartCh.hasSubscribers) { |
We should have a test that spys whether the afterStartCh handler was called (or some way to verify this behaviour E2E).
There was a problem hiding this comment.
You're right, Igor I miss some kafka tests, like we have for express in packages/dd-trace/test/appsec/iast/analyzers/unvalidated-redirect-analyzer.express.plugin.spec.js
Something testing that we are detecting vulnerabilities in kafka.
PS: the typo is in var definition also, so it is not a bug, just a typo :-)
There was a problem hiding this comment.
oops, totally forgotten
There was a problem hiding this comment.
* kafka poc * IastContextPlugin tests * More tests * Upgrade taint-tracking version to 1.7.0 * More tests * Increase tests coverage * Rename kafka message sources * Remove parameterName from kafka tainteds and propagate tainted type in JSON.parse * Move taintObject method to its own module to avoid circular references in taint-tracking-impl * Remove json.value from source-types * Rename kafkajs channels * add afterStart and beforeFinish tests and fix typo * Remove not used handler from startCtxOn and finishCtxOn * Fix kafkajs tests * Sort csiMethod * Kafka message tainting integration test
* kafka poc * IastContextPlugin tests * More tests * Upgrade taint-tracking version to 1.7.0 * More tests * Increase tests coverage * Rename kafka message sources * Remove parameterName from kafka tainteds and propagate tainted type in JSON.parse * Move taintObject method to its own module to avoid circular references in taint-tracking-impl * Remove json.value from source-types * Rename kafkajs channels * add afterStart and beforeFinish tests and fix typo * Remove not used handler from startCtxOn and finishCtxOn * Fix kafkajs tests * Sort csiMethod * Kafka message tainting integration test
* kafka poc * IastContextPlugin tests * More tests * Upgrade taint-tracking version to 1.7.0 * More tests * Increase tests coverage * Rename kafka message sources * Remove parameterName from kafka tainteds and propagate tainted type in JSON.parse * Move taintObject method to its own module to avoid circular references in taint-tracking-impl * Remove json.value from source-types * Rename kafkajs channels * add afterStart and beforeFinish tests and fix typo * Remove not used handler from startCtxOn and finishCtxOn * Fix kafkajs tests * Sort csiMethod * Kafka message tainting integration test
* kafka poc * IastContextPlugin tests * More tests * Upgrade taint-tracking version to 1.7.0 * More tests * Increase tests coverage * Rename kafka message sources * Remove parameterName from kafka tainteds and propagate tainted type in JSON.parse * Move taintObject method to its own module to avoid circular references in taint-tracking-impl * Remove json.value from source-types * Rename kafkajs channels * add afterStart and beforeFinish tests and fix typo * Remove not used handler from startCtxOn and finishCtxOn * Fix kafkajs tests * Sort csiMethod * Kafka message tainting integration test
* kafka poc * IastContextPlugin tests * More tests * Upgrade taint-tracking version to 1.7.0 * More tests * Increase tests coverage * Rename kafka message sources * Remove parameterName from kafka tainteds and propagate tainted type in JSON.parse * Move taintObject method to its own module to avoid circular references in taint-tracking-impl * Remove json.value from source-types * Rename kafkajs channels * add afterStart and beforeFinish tests and fix typo * Remove not used handler from startCtxOn and finishCtxOn * Fix kafkajs tests * Sort csiMethod * Kafka message tainting integration test
* kafka poc * IastContextPlugin tests * More tests * Upgrade taint-tracking version to 1.7.0 * More tests * Increase tests coverage * Rename kafka message sources * Remove parameterName from kafka tainteds and propagate tainted type in JSON.parse * Move taintObject method to its own module to avoid circular references in taint-tracking-impl * Remove json.value from source-types * Rename kafkajs channels * add afterStart and beforeFinish tests and fix typo * Remove not used handler from startCtxOn and finishCtxOn * Fix kafkajs tests * Sort csiMethod * Kafka message tainting integration test
What does this PR do?
KafkajsConsumerPluginto publish events when a consumer starts and finishes handling a messageKafkaContextPlugin, it creates and destroys an iastContextKafkaConsumerIastPluginreceives the events, it taints the kafka message key and value.kafka.message.keyandkafka.message.valueJSON.parsecalls to help with the taint tracking (for the case the kafka qeue that is encoding the messages as json)Motivation
Be able to detect vulnerabilities in kafka consumers treating kafka messages as a source of "dangerous" input.
Plugin Checklist
Additional Notes
For non appsec team reviewers: IAST needs to be notified after the kafka consumer span is created and before span is finished so this PR introduces two new channels (
dd-trace:kafkajs:consumer:afterStartanddd-trace:kafkajs:consumer:beforeFinish) inKafkajsConsumerPluginto notify when such events occur.Security
Datadog employees:
@DataDog/security-design-and-guidance.Unsure? Have a question? Request a review!