Skip to content

RUM-3100 generate checksum xml#2695

Merged
xgouchet merged 4 commits into
developfrom
xgouchet/RUM-3100/add_checksum_to_maven
Jun 4, 2025
Merged

RUM-3100 generate checksum xml#2695
xgouchet merged 4 commits into
developfrom
xgouchet/RUM-3100/add_checksum_to_maven

Conversation

@xgouchet

@xgouchet xgouchet commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Gradle allows developers to add a verification-metadata.xml file to their project to pin dependencies with a specific hash or PGP signature. This prevents attack if the artifact repository is compromised.

Note

When publishing an artifact to Maven, the hash is automatically computed, and downloaded by Gradle with the artifact itself. If the verification-metadata.xml is present, it will compare the downloaded hash with the one in the xml file and abort the build if they don't match.

In order to improve our customer's trust in our artifact, this PR will generate a verification-metadata.xml file for each published artifact (as part of the publish:<module> job), and a new job will create a merged verification-metadata.xml that we can publish on GitHub and customers can refer to to ensure at any given time that the hash present in Maven is the expected one.

@xgouchet
xgouchet requested review from a team as code owners June 3, 2025 13:09
@codecov-commenter

codecov-commenter commented Jun 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.98%. Comparing base (9d00117) to head (75b942f).
⚠️ Report is 2047 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2695      +/-   ##
===========================================
- Coverage    70.07%   69.98%   -0.09%     
===========================================
  Files          822      822              
  Lines        30693    30693              
  Branches      5170     5170              
===========================================
- Hits         21508    21479      -29     
- Misses        7755     7770      +15     
- Partials      1430     1444      +14     

see 37 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc

import sys

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great job !!
I am wondering where is this merger going to be used ? I am not seeing it yet in the code, is that correct ?

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.

It's used in a new Gitlab job

@mariusc83 mariusc83 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am thinking, should we add also some docs on how this should be verified on their end ? how should they use this xml ?

Comment thread .gitlab-ci.yml
- !reference [.snippets, set-publishing-credentials]
- ./gradlew :integrations:dd-sdk-android-glide:publishToSonatype --stacktrace --no-daemon
- ./gradlew :features:dd-sdk-android-rum:publishToSonatype --stacktrace --no-daemon
artifacts:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's this config doing ?

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.

This will extract the generated XML for each module (as each one is published to Maven in its own job) so that it can be merged later in the new job.

Comment thread .gitlab-ci.yml
- publish:release-okhttp
- publish:release-okhttp-otel
- publish:release-benchmark
script:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok I see the script is being used here, I wonder what's the purpose of this merged file ?

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.

The purpose is to have a single XML file to provide our customers with all sha256 there.
I thought about publishing all the individual xml files, but that would be a hassle, compared to just copy-pasting the content of a single file in their own verification-metadata.xml. Even if they have hashes for unnecessary libs, it'll still work.

0xnm
0xnm previously approved these changes Jun 3, 2025

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm! nice job.

I left some comments, but nothing blocking.

Comment thread .gitlab-ci.yml Outdated
when: on_success
expire_in: 7 days
paths:
- dd-sdk-android-internal/verification-metadata.xml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

probably it should be tools/dd-sdk-android-benchmark-internal/verification-metadata.xml here?

anyway, we can skip metadata publication here, because this one is only consumed by our internal apps and we don't want to enable verification there, we don't need it.

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.

Good catch

xmlns = NS_DEPS_VERIF
TAG_CONFIGURATION {
TAG_VERIF_METADATA { -true.toString() }
TAG_VERIF_SIGNATURE { -false.toString() } // TODO-RUM-3104 add signature verification

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
TAG_VERIF_SIGNATURE { -false.toString() } // TODO-RUM-3104 add signature verification
TAG_VERIF_SIGNATURE { -false.toString() } // TODO RUM-3104 add signature verification

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.

Good call

import java.io.File
import java.security.MessageDigest

open class GenerateVerificationXmlTask : DefaultTask() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

so it seems there is no Gradle built-in way to generate it? It seems that one can use https://github.com/sigstore/sigstore-java, but indeed it may be simpler to generate it manually.

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.

Gradle can only generate it for the depdencies your project is using but not for a library you're publishing (I couldn't find any doc for library maintainers at all), so for now I think it's better to do it manually.
I did check that the sha256 computed here matches the one when we publish to Maven (checked with publishToMavenLocal)

import java.io.File
import java.security.MessageDigest

open class GenerateVerificationXmlTask : DefaultTask() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we have a test/validation that generated XML indeed matches the schema?

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.

That's a good point, I'll try and see if I can write a test for that 👍

mariusc83
mariusc83 previously approved these changes Jun 3, 2025
ambushwork
ambushwork previously approved these changes Jun 3, 2025
Comment thread .gitlab-ci.yml Outdated
@xgouchet

xgouchet commented Jun 3, 2025

Copy link
Copy Markdown
Contributor Author

@mariusc83

should we add also some docs on how this should be verified on their end ? how should they use this xml ?

I'll add a doc in confluence on the process, the idea is to have the doc published in our release notes on github.

@xgouchet
xgouchet dismissed stale reviews from ambushwork, mariusc83, and 0xnm via 75b942f June 3, 2025 17:42
@xgouchet
xgouchet force-pushed the xgouchet/RUM-3100/add_checksum_to_maven branch from 0b289ea to 75b942f Compare June 3, 2025 17:42
@xgouchet
xgouchet requested review from 0xnm, ambushwork and mariusc83 June 3, 2025 20:48
@xgouchet
xgouchet merged commit e2c7dfa into develop Jun 4, 2025
@xgouchet
xgouchet deleted the xgouchet/RUM-3100/add_checksum_to_maven branch June 4, 2025 14:10
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.

5 participants