Skip to content

Add DD_APPSEC_SCA_ENABLED new configuration variable#2557

Merged
estringana merged 6 commits intomasterfrom
estringana/add-appsec-sca
Mar 14, 2024
Merged

Add DD_APPSEC_SCA_ENABLED new configuration variable#2557
estringana merged 6 commits intomasterfrom
estringana/add-appsec-sca

Conversation

@estringana
Copy link
Copy Markdown
Contributor

Description

It is required to create a new configuration variable DD_APPSEC_SCA_ENABLED so customers can enable SCA. This variable is reported to the backend via telemetry and used there.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

APPSEC-14721

@estringana estringana force-pushed the estringana/add-appsec-sca branch from d812229 to fa41d2a Compare March 5, 2024 15:51
@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Mar 5, 2024

Benchmarks

Benchmark execution time: 2024-03-05 16:23:25

Comparing candidate commit fa41d2a in PR branch estringana/add-appsec-sca with baseline commit dc24c31 in branch master.

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

scenario:PDOBench/benchPDOBaseline

  • 🟩 execution_time [-16.340µs; -13.325µs] or [-8.609%; -7.020%]

scenario:PDOBench/benchPDOBaseline-opcache

  • 🟥 execution_time [+15.141µs; +16.403µs] or [+8.668%; +9.391%]

scenario:PDOBench/benchPDOOverhead

  • 🟩 execution_time [-18.074µs; -16.050µs] or [-6.292%; -5.588%]

scenario:PDOBench/benchPDOOverhead-opcache

  • 🟥 execution_time [+14.981µs; +17.044µs] or [+5.321%; +6.054%]

scenario:PDOBench/benchPDOOverheadWithDBM

  • 🟩 execution_time [-18.020µs; -15.859µs] or [-5.828%; -5.129%]

scenario:PDOBench/benchPDOOverheadWithDBM-opcache

  • 🟥 execution_time [+15.028µs; +18.456µs] or [+4.861%; +5.970%]

Copy link
Copy Markdown
Contributor

@Anilm3 Anilm3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there perhaps any tests showing that this variable is actually being sent?

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 6, 2024

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.91%. Comparing base (dc24c31) to head (887c380).
⚠️ Report is 897 commits behind head on master.

Files with missing lines Patch % Lines
ext/configuration.c 75.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (80.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2557      +/-   ##
============================================
- Coverage     77.08%   75.91%   -1.17%     
  Complexity     2574     2574              
============================================
  Files           214      240      +26     
  Lines         23057    27033    +3976     
  Branches          0      976     +976     
============================================
+ Hits          17773    20522    +2749     
- Misses         5284     5991     +707     
- Partials          0      520     +520     
Flag Coverage Δ
appsec-extension 69.13% <ø> (?)
tracer-extension 78.70% <80.00%> (-0.01%) ⬇️
tracer-php 75.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ext/configuration.h 100.00% <ø> (ø)
ext/telemetry.c 100.00% <100.00%> (ø)
ext/configuration.c 78.26% <75.00%> (-0.21%) ⬇️

... and 26 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc24c31...887c380. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@estringana estringana marked this pull request as ready for review March 6, 2024 13:16
@estringana estringana requested a review from a team as a code owner March 6, 2024 13:16
Comment thread ext/telemetry.c Outdated
ddog_ConfigurationOrigin origin = DDOG_CONFIGURATION_ORIGIN_DEFAULT;
if (!zend_string_equals_cstr(ini->value, cfg->default_encoded_value.ptr, cfg->default_encoded_value.len)) {
origin = cfg->name_index >= 0 ? DDOG_CONFIGURATION_ORIGIN_ENV_VAR : DDOG_CONFIGURATION_ORIGIN_CODE;
} else {
Copy link
Copy Markdown
Contributor Author

@estringana estringana Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that when a configuration is explicitly defined as a env/ini with the same value as the default value of that config, the value sent to telemetry was default and it should be EnvVar instead

@estringana estringana requested a review from bwoebi March 6, 2024 14:02
@estringana estringana force-pushed the estringana/add-appsec-sca branch from 1b1225b to 7f6fc56 Compare March 6, 2024 14:07
@bwoebi
Copy link
Copy Markdown
Collaborator

bwoebi commented Mar 6, 2024

I think you should test datadog.appsec.sca_enabled=1 in one of the tests instead of using the ENV there. I believe it needs to be handled in configuration.c so that it's parsed as datadog.appsec.sca_enabled instead of datadog.appsec_sca_enabled.

@estringana estringana force-pushed the estringana/add-appsec-sca branch from da51431 to 0f417ed Compare March 7, 2024 12:19
@estringana
Copy link
Copy Markdown
Contributor Author

I think you should test datadog.appsec.sca_enabled=1 in one of the tests instead of using the ENV there. I believe it needs to be handled in configuration.c so that it's parsed as datadog.appsec.sca_enabled instead of datadog.appsec_sca_enabled.

Thanks for pointing that out @bwoebi . If I understood correctly, I fixed it

@estringana
Copy link
Copy Markdown
Contributor Author

@bwoebi pr is ready. Can you review when you have a chance please?

Comment thread ext/configuration.c Outdated
Comment on lines 148 to 154
if (env_name.ptr == strstr(env_name.ptr, "DD_APPSEC_")) {
ini_name->ptr[sizeof("datadog.appsec") - 1] = '.';
}

if (env_name.ptr == strstr(env_name.ptr, "DD_TRACE_")) {
ini_name->ptr[sizeof("datadog.trace") - 1] = '.';
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reorder this and put an else if there? Just to avoid eval of strstr when unnecessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Done

Copy link
Copy Markdown
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM :-)

@estringana estringana merged commit 31e95da into master Mar 14, 2024
@estringana estringana deleted the estringana/add-appsec-sca branch March 14, 2024 11:12
@github-actions github-actions Bot added this to the 0.99.0 milestone Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants