Skip to content

Conversation

@davand01
Copy link

Updated grafana and grafanaserviceaccount and added a new detector for grafana api keys.

Description:

Added one new detector for generic grafana api keys. Also updated the patterns and some of the logic for GLSA Service Account tokens and GLC tokens.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

Updated grafana and grafanaserviceaccount and added a new detector for grafana api keys.
@davand01 davand01 requested review from a team as code owners August 20, 2025 15:02
}

if verify {
res.SetVerificationError(fmt.Errorf("no grafana instance detected to verify against"), match)
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't seem to be verifying the matched credentials

Copy link
Author

Choose a reason for hiding this comment

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

These kind of api keys are used for on-premise installations, so together with a custom endpoint that could be an IP address or a FQDN. Since it's hard to reliably identify it - there is no good way of verifying the matched credentials.

Copy link
Contributor

Choose a reason for hiding this comment

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

Verification logic has to exist in a detector. In docs, it is mentioned that Grafana can be hosted on a VPS or as a subdomain. Gitlab detector is the best example for this

@davand01 davand01 requested a review from nabeelalam August 26, 2025 15:46
// Grafana uses "eyJrIjoi" as a prefix for api keys, see for example.
// https://github.com/grafana/pyroscope-dotnet/blob/0c17634653af09befa7bc07b2e1c420b5dc8578c/tracer/src/Datadog.Trace/Iast/Analyzers/HardcodedSecretsAnalyzer.cs#L173
func (s Scanner) Keywords() []string {
return []string{"grafanaapikey", "eyJrIjoi"}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use "eyJrIjoi" exclusively since it's always part of the key. A keyword match for "grafanaapikey" won't necessarily contain eyJrIjoi in its input.

Copy link
Author

Choose a reason for hiding this comment

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

Doh. PEBKAC.... I'll update that :P

}

if verify {
res.SetVerificationError(fmt.Errorf("no grafana instance detected to verify against"), match)
Copy link
Contributor

Choose a reason for hiding this comment

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

Verification logic has to exist in a detector. In docs, it is mentioned that Grafana can be hosted on a VPS or as a subdomain. Gitlab detector is the best example for this

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for updating SATs too

Comment on lines +92 to +105
resp, err := client.Do(req)
if err == nil {
defer resp.Body.Close()
switch {
case resp.StatusCode >= 200 && resp.StatusCode < 300:
res.Verified = true
case resp.StatusCode == 401:
// determinately not verified
default:
res.SetVerificationError(fmt.Errorf("unexpected HTTP response status %d", resp.StatusCode), key)
}
} else {
res.SetVerificationError(err, key)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

While we're at it, can we add indeterminate verification support here?
Here's an example

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.

4 participants