DataDog / datadog-static-analyzer

Datadog Static Analyzer
https://docs.datadoghq.com/static_analysis/
Apache License 2.0
100 stars 12 forks source link

[STAL-2687] Fetch remote config #489

Closed juli1 closed 2 months ago

juli1 commented 2 months ago

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