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

Add SCA enablement state in telemetry messages #3563

Merged
merged 15 commits into from
Jun 10, 2024
Merged

Conversation

vpellan
Copy link
Contributor

@vpellan vpellan commented Mar 29, 2024

What does this PR do?

This PR adds SCA enablement state in configuration payloads that are sent in app-started and app-client-configuration-change Telemetry messages

Motivation:

Customers need a way to enable SCA via an environment variable. If set, this variable must be sent to the backend through Telemetry messages

How to test the change?

The tests are included in the corresponding rspec files
Link to the corresponding PR in system-tests repo

For Datadog employees:

  • If this PR 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.
  • This PR doesn't touch any of that.

Unsure? Have a question? Request a review!

@vpellan vpellan added core Involves Datadog core libraries feature Involves a product feature appsec Application Security monitoring product labels Mar 29, 2024
@vpellan vpellan requested review from a team as code owners March 29, 2024 15:45
@github-actions github-actions bot added the integrations Involves tracing integrations label Mar 29, 2024
@vpellan vpellan changed the title Remove redundant comment Add SCA enablement state in telemetry messages Mar 29, 2024
@codecov-commenter
Copy link

codecov-commenter commented Apr 2, 2024

Codecov Report

Attention: Patch coverage is 97.77778% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.11%. Comparing base (eab4b6e) to head (af5570b).
Report is 2 commits behind head on master.

Files Patch % Lines
lib/datadog/core/telemetry/event.rb 91.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3563   +/-   ##
=======================================
  Coverage   98.11%   98.11%           
=======================================
  Files        1225     1225           
  Lines       72743    72783   +40     
  Branches     3479     3482    +3     
=======================================
+ Hits        71369    71409   +40     
  Misses       1374     1374           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from telemetry-2.0 to master April 3, 2024 18:54
@vpellan vpellan force-pushed the vpellan/sca-enablement branch 3 times, most recently from c819632 to ddcb89d Compare April 17, 2024 12:25
@vpellan vpellan added this to the 1.23.0 milestone Apr 17, 2024
@TonyCTHsu TonyCTHsu removed this from the 1.22.1 milestone Apr 17, 2024
@vpellan
Copy link
Contributor Author

vpellan commented May 7, 2024

Waiting for 2.0 to be released

list << conf_value('appsec.enabled', config.dig('appsec', 'enabled')) if config.respond_to?('appsec')
if config.respond_to?('appsec')
list << conf_value('appsec.enabled', config.dig('appsec', 'enabled'))
list << conf_value('appsec.sca_enabled', config.dig('appsec', 'sca_enabled'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the other options (lines 110 and 113 in this file), the pattern appears to be component.function.enabled, i.e. in this case it would be appsec.sca.enabled. Is the x_enabled pattern used elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that it would be better, but the corresponding RFC (https://docs.google.com/document/d/1xTLC3UEGNooZS0YOYp3swMlAhtvVn1aa639TGxHHYvg) specifies appsec.sca_enabled in the telemetry paragraph

@@ -13,7 +13,6 @@ module Datadog
module AppSec
module Contrib
module Rack
# Create an array of lowercased headers
Copy link
Member

Choose a reason for hiding this comment

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

Did you remove this comment because it was incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it is not incorrect but it doesn't add anything (it was originally saying more than that but I factorised the corresponding code, and the comment with it, which led to this not very useful comment that I forgot to delete) (#3528 (comment))

Comment on lines 247 to +271
def payload(seq_id)
{
configuration: @changes.map do |name, value|
{
name: name,
value: value,
origin: @origin,
}
end
}
{ configuration: configuration(seq_id) }
end

def configuration(seq_id)
config = Datadog.configuration

res = @changes.map do |name, value|
{
name: name,
value: value,
origin: @origin,
}
end

unless config.dig('appsec', 'sca_enabled').nil?
res << {
name: 'appsec.sca_enabled',
value: config.appsec.sca_enabled,
origin: 'code',
seq_id: seq_id,
}
end

res
Copy link
Member

@marcotc marcotc May 16, 2024

Choose a reason for hiding this comment

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

This payload is only used for remote configuration changes today.
Is DD_APPSEC_SCA_ENABLED remotely configurable?
I asked because this method should have no product specific code, everything should come through the changes argument to AppClientConfigurationChange.new(changes, origin).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to this document (https://docs.google.com/document/d/12NBx-nD-IoQEMiCRnJXneq4Be7cbtSc6pJLOFUWTpNE), DD_APPSEC_SCA_ENABLED is remotely configurable

@marcotc marcotc merged commit acd3feb into master Jun 10, 2024
167 checks passed
@marcotc marcotc deleted the vpellan/sca-enablement branch June 10, 2024 18:19
@github-actions github-actions bot added this to the 2.1.0 milestone Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appsec Application Security monitoring product core Involves Datadog core libraries feature Involves a product feature integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants