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

[STAL-2687] Fetch remote config #489

Merged
merged 8 commits into from
Aug 14, 2024
Merged

[STAL-2687] Fetch remote config #489

merged 8 commits into from
Aug 14, 2024

Conversation

juli1
Copy link
Collaborator

@juli1 juli1 commented Aug 13, 2024

What problem are you trying to solve?

We want to be able to fetch the configuration remotely.

Solution

We attempt to read the configuration file

  1. If there is a configuration file, we attempt to get the remote configuration by passing the existing config file and the backend returns the final config
  2. If there is no config, we retrieve the remote configuration by passing a null configuration to the API

Notes

  1. We fetch the remote configuration ONLY if we have some API keys defined. Otherwise, we do not even try
  2. We added a lot of debug information so that customer will be able to troubleshoot

Testing

Tested locally, existing tests should pass

cargo run --bin datadog-static-analyzer -- --staging --directory /Users/julien.delange/git/datadog-ci --format sarif --output ~/plop.json  --debug yes 
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running `target/debug/datadog-static-analyzer --staging --directory /Users/julien.delange/git/datadog-ci --format sarif --output /Users/julien.delange/plop.json --debug yes`
Remote config (base64): "cnVsZXNldHM6CiAgLSBvcmctcnVsZXNldAogIC0ga2Rza2xmanNsZGYK"
Error: ruleset org-ruleset not found
Error: error when reading rules from API

Caused by:
    Error: ruleset org-ruleset not found

@juli1 juli1 requested a review from a team as a code owner August 13, 2024 20:20
@juli1 juli1 requested a review from jacobotb August 13, 2024 20:20
crates/cli/src/config_file.rs Outdated Show resolved Hide resolved
crates/cli/src/config_file.rs Outdated Show resolved Hide resolved
crates/cli/src/config_file.rs Outdated Show resolved Hide resolved
crates/cli/src/config_file.rs Outdated Show resolved Hide resolved
crates/cli/src/config_file.rs Outdated Show resolved Hide resolved
crates/cli/src/datadog_utils.rs Outdated Show resolved Hide resolved
crates/cli/src/datadog_utils.rs Outdated Show resolved Hide resolved
crates/cli/src/git_utils.rs Outdated Show resolved Hide resolved

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ConfigResponseData {
#[serde(rename = "id")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not asking you to remove, but as an FYI renames are not needed for field names that are the exact same as the json.

crates/bins/src/bin/datadog-static-analyzer.rs Outdated Show resolved Hide resolved
juli1 and others added 4 commits August 13, 2024 21:05
Co-authored-by: Amaan Qureshi <amaan.qureshi@datadoghq.com>
Co-authored-by: Amaan Qureshi <amaan.qureshi@datadoghq.com>
@juli1 juli1 requested a review from amaanq August 14, 2024 01:17
crates/cli/src/config_file.rs Outdated Show resolved Hide resolved
@juli1 juli1 merged commit 9e0f20d into main Aug 14, 2024
64 checks passed
@jasonforal jasonforal deleted the juli1/fetch-remote-config branch November 8, 2024 09:40
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.

2 participants