grapl-security / grapl

Graph platform for Detection and Response
https://www.graplsecurity.com
Apache License 2.0
686 stars 78 forks source link

Plugin health should be checked from Consul health, not Nomad job status #2087

Closed wimax-grapl closed 2 years ago

wimax-grapl commented 2 years ago

Which issue does this PR correspond to?

https://github.com/grapl-security/issue-tracker/issues/1063 https://app.zenhub.com/workspaces/grapl-6036cbd36bacff000ef314f2/issues/grapl-security/issue-tracker/1063

What changes does this PR make to Grapl? Why?

The current GetPluginHealth implementation is bad and wrong. It only checks "is the Nomad job running?" and not "is the Consul service healthy?" This is a stab at doing that. It seems to work.

Also added a test utility for checking eventual health (seems to happen in 20-30s after deploying a plugin)

How were these changes tested?

Integrated this RPC into tests. Itactually helped me catch a bug in grapl-web-ui!

codecov[bot] commented 2 years ago

Codecov Report

Base: 34.44% // Head: 34.42% // Decreases project coverage by -0.01% :warning:

Coverage data is based on head (a3677cc) compared to base (aa575b2). Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2087 +/- ## ========================================== - Coverage 34.44% 34.42% -0.02% ========================================== Files 304 306 +2 Lines 5299 5304 +5 ========================================== + Hits 1825 1826 +1 - Misses 3474 3478 +4 ``` | [Impacted Files](https://codecov.io/gh/grapl-security/grapl/pull/2087?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security) | Coverage Δ | | |---|---|---| | [src/rust/consul-client/src/lib.rs](https://codecov.io/gh/grapl-security/grapl/pull/2087/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security#diff-c3JjL3J1c3QvY29uc3VsLWNsaWVudC9zcmMvbGliLnJz) | `0.00% <0.00%> (ø)` | | | [src/rust/consul-client/src/models.rs](https://codecov.io/gh/grapl-security/grapl/pull/2087/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security#diff-c3JjL3J1c3QvY29uc3VsLWNsaWVudC9zcmMvbW9kZWxzLnJz) | `0.00% <0.00%> (ø)` | | | [.../rust/grapl-web-ui/src/routes/api/plugin/create.rs](https://codecov.io/gh/grapl-security/grapl/pull/2087/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security#diff-c3JjL3J1c3QvZ3JhcGwtd2ViLXVpL3NyYy9yb3V0ZXMvYXBpL3BsdWdpbi9jcmVhdGUucnM=) | `0.00% <ø> (ø)` | | | [...st/plugin-registry/src/server/get\_plugin\_health.rs](https://codecov.io/gh/grapl-security/grapl/pull/2087/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security#diff-c3JjL3J1c3QvcGx1Z2luLXJlZ2lzdHJ5L3NyYy9zZXJ2ZXIvZ2V0X3BsdWdpbl9oZWFsdGgucnM=) | `0.00% <0.00%> (ø)` | | | [.../src/graplinc/grapl/api/plugin\_registry/v1beta1.rs](https://codecov.io/gh/grapl-security/grapl/pull/2087/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security#diff-c3JjL3J1c3QvcnVzdC1wcm90by9zcmMvZ3JhcGxpbmMvZ3JhcGwvYXBpL3BsdWdpbl9yZWdpc3RyeS92MWJldGExLnJz) | `60.75% <ø> (ø)` | | | [...rust-proto/src/graplinc/grapl/api/graph/v1beta1.rs](https://codecov.io/gh/grapl-security/grapl/pull/2087/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security#diff-c3JjL3J1c3QvcnVzdC1wcm90by9zcmMvZ3JhcGxpbmMvZ3JhcGwvYXBpL2dyYXBoL3YxYmV0YTEucnM=) | `55.07% <0.00%> (+0.30%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=grapl-security)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.