[K9VULN-12867] Add User-Agent header to rule fetch requests#889
Merged
colemaring merged 6 commits intomainfrom Apr 30, 2026
Merged
[K9VULN-12867] Add User-Agent header to rule fetch requests#889colemaring merged 6 commits intomainfrom
colemaring merged 6 commits intomainfrom
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: 984d131 | Docs | Datadog PR Page | Give us feedback! |
bahar-shah
previously approved these changes
Apr 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds version-identifying User-Agent information to outbound requests made by the CLI when fetching static-analysis rules, enabling backend correlation/metrics by CLI version/revision.
Changes:
- Add
User-Agent: datadog-static-analyzer/<semver> (<git-sha>)header to requests built bymake_request. - Introduce
build_user_agent()helper and a small unit test for its formatting. - Add new CLI constants for the
User-Agentheader and product name.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/cli/src/datadog_utils.rs |
Builds and attaches a versioned User-Agent header to outgoing requests; adds a unit test. |
crates/cli/src/constants.rs |
Defines User-Agent header key and product name constants used by the CLI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jasonforal
reviewed
Apr 23, 2026
jasonforal
previously approved these changes
Apr 23, 2026
e598435 to
be41153
Compare
be41153 to
8944b97
Compare
jasonforal
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When a bug is identified on a specific version of
datadog-static-analyzer, there's no way to correlate API calls to a CLI version. See K9VULN-12867. This adds aUser-Agentheader to every outbound rule-fetch request so the backend can emit a metric by version.Changes
User-Agent: datadog-static-analyzer/<semver>-<git-sha>header to all requests inmake_requestTesting
Deployed
static-analysis-apito staging to test this PR.The following was ran to built the binary on a SHA to simulate release.yml. Otherwise, the user agent would show as
datadog-static-analyzer/x.x.x-developmentI ran the binary to generate the following trace (with this PR deployed to staging):

trace
metrics
Note
This wont apply to CWP since CWP uses a separate client to fetch rules.